home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / util / moni / Scout-src.lha / source / Scout.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-02-13  |  83.4 KB  |  2,427 lines

  1. /**
  2.  * Scout - The Amiga System Monitor
  3.  *
  4.  *------------------------------------------------------------------
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  * You must not use this source code to gain profit of any kind!
  21.  *
  22.  *------------------------------------------------------------------
  23.  *
  24.  * @author Andreas Gelhausen
  25.  * @author Richard Körber <rkoerber@gmx.de>
  26.  */
  27.  
  28.  
  29.  
  30. #include "system_headers.h"
  31.  
  32. /*********************************************************************
  33.                            Definitionen
  34. *********************************************************************/
  35. #define MYLIBVERSION    37
  36. #define MUIVERSION      8
  37.  
  38. /*********************************************************************
  39.                          Globale Variablen
  40. *********************************************************************/
  41. extern struct  ExecBase *SysBase;
  42.  
  43. struct Library          *MUIMasterBase;
  44. struct Library          *IdentifyBase;
  45. struct Library          *CxBase;
  46. struct Library          *LayersBase;
  47.  
  48. struct Device           *TimerBase;
  49.  
  50. struct Task             *myprocess;
  51. struct MsgPort          *myarexxport,*ScoutPort;
  52. BOOL   ScoutPortAdded = FALSE;
  53.  
  54. struct IOStdReq         *InputIORequest;
  55. BOOL   input = TRUE, timer2 = TRUE;
  56. struct timerequest      *TimerIORequest;
  57. BYTE   TimerSignal;
  58.  
  59. BOOL   input;
  60. char   *portname;
  61.  
  62. /*
  63. **  MUI
  64. */
  65.  
  66. APTR AP_Scout;
  67.  
  68. APTR WI_Main,WI_About;
  69. APTR WI_Memory,WI_Interrupts,WI_Semaphores;
  70. APTR WI_InputHandler,WI_Residents,WI_Windows,WI_Expansions;
  71. APTR WI_Fonts,WI_Vectors,WI_Mount;
  72. APTR WI_Priority,SL_Priority;
  73. APTR WI_Signal;
  74. APTR WI_LowMemory;
  75. APTR WI_Timer;
  76. APTR WI_Allocations;
  77.  
  78. APTR memlist,intlist;
  79. APTR resilist;
  80. APTR inputlist;
  81. APTR lowmemorylist;
  82. APTR timerlist;
  83.  
  84. APTR memtext,inttext;
  85. APTR resitext;
  86. APTR inputtext;
  87. APTR lowmemorytext;
  88. APTR timertext;
  89. APTR vectext1,vectext2,vectext3,vectext4;
  90. APTR pritext1,pritext2,pritext3;
  91. APTR sigtext1,sigtext2,sigtext3,sigtext4;
  92. APTR alctext1,alctext2,alctext3;
  93.  
  94. APTR resicount,inputcount,intcount,lowmemorycount,timercount;
  95. int  resicnt,inputcnt,intcnt,lowmemorycnt,timercnt;
  96.  
  97. APTR BT_Ports,BT_Residents,BT_Interrupts,BT_InputHandler,BT_Tasks,BT_Locks;
  98. APTR BT_Libraries,BT_Devices,BT_Resources,BT_Memory,BT_Windows,BT_Semaphores;
  99. APTR BT_Assigns,BT_Fonts,BT_Expansions,BT_Vectors,BT_Mount,BT_Commands;
  100. APTR BT_System,BT_Commodities,BT_Classes,BT_LowMemory,BT_ScreenMode,BT_Allocations,BT_Timer;
  101.  
  102. APTR BT_AboutContinue;
  103. APTR BT_MemPrint,BT_MemPriority,BT_MemMore,BT_MemExit;
  104. APTR BT_IntUpdate,BT_IntPrint,BT_IntRemove,BT_IntMore,BT_IntExit;
  105. APTR BT_InputUpdate,BT_InputPrint,BT_InputRemove,BT_InputPriority,BT_InputExit;
  106. APTR BT_ResiUpdate,BT_ResiPrint,BT_ResiMore,BT_ResiExit;
  107. APTR BT_VecUpdate,BT_VecPrint,BT_VecExit;
  108. APTR BT_SysPrint,BT_SysExit,BT_SysUpdate;
  109. APTR BT_PriorityOK,BT_PriorityCancel;
  110. APTR BT_SignalOK,BT_SignalCancel;
  111. APTR BT_LowMemoryUpdate,BT_LowMemoryPrint,BT_LowMemoryRemove,BT_LowMemoryPriority,BT_LowMemoryExit;
  112. APTR BT_LowMemoryCause;
  113. APTR BT_TimerUpdate,BT_TimerPrint,BT_TimerRemove,BT_TimerExit;
  114. APTR BT_AlcUpdate,BT_AlcPrint,BT_AlcExit;
  115.  
  116. APTR AboutText;
  117.  
  118. APTR liblist_cmphook_ptr;
  119. APTR devlist_cmphook_ptr;
  120. APTR reslist_cmphook_ptr;
  121. APTR tasklist_cmphook_ptr;
  122. APTR portlist_cmphook_ptr;
  123. APTR comlist_cmphook_ptr;
  124. APTR asslist_cmphook_ptr;
  125. APTR locklist_cmphook_ptr;
  126. APTR cxlist_cmphook_ptr;
  127. APTR classlist_cmphook_ptr;
  128. APTR smodelist_cmphook_ptr;
  129.  
  130. APTR processorvalue, customvalue;
  131. APTR processortext, customtext;
  132.  
  133. #define ID_QUIT  MUIV_Application_ReturnID_Quit
  134.  
  135. APTR GlobalPool;
  136.  
  137. BPTR     printfile, prevdir;
  138. unsigned char     *tmpstr,*tmpstr2;
  139.  
  140. char UpdateText[]    = "_Update";
  141. char RemoveText[]    = "_Remove";
  142. char CloseText[]     = "_Close";
  143. char PriorityText[]  = "_Priority";
  144. char MoreText[]      = "_More";
  145. char ExitText[]      = "E_xit";
  146. char FreezeText[]    = "_Freeze";
  147. char ActivateText[]  = "_Activate";
  148. char SignalText[]    = "_Signal";
  149. char BreakText[]     = "_Break";
  150. char ContinueText[]  = "_Continue";
  151. char CancelText[]    = "_Cancel";
  152. char OKText[]        = "_OK";
  153. char ReleaseText[]   = "Re_lease";
  154. char ObtainText[]    = "_Obtain";
  155. char PrintText[]     = "Pr_int";
  156. char ToFrontText[]   = "To _Front";
  157. char AppearText[]    = "_Appear";
  158. char DisappearText[] = "_Disappear";
  159. char EnableText[]    = "_Enable";
  160. char DisableText[]   = "Di_sable";
  161. char KillText[]      = "_Kill";
  162. char ListChgText[]   = "List_Chg";
  163. char UniqueText[]    = "U_nique";
  164. char CauseText[]     = "_Cause";
  165. char FunctionsText[] = "_Functions";
  166.  
  167. char AllocationsText[]  = "Allocations";      /*-*/
  168. char AssignsText[]      = "Assigns";
  169. char ClassesText[]      = "BoopsiClasses";    /*-*/
  170. char CommoditiesText[]  = "Commodities";      /*-*/
  171. char DevicesText[]      = "Devices";
  172. char CommandsText[]     = "Resident Cmds";
  173. char ExpansionsText[]   = "Expansions";
  174. char FontsText[]        = "Fonts";
  175. char InputHandlersText[]= "InputHandlers";
  176. char InterruptsText[]   = "Interrupts";
  177. char LibrariesText[]    = "Libraries";
  178. char LocksText[]        = "Locks";
  179. char LowMemoryText[]    = "LowMemory";        /*-*/
  180. char MemoryText[]       = "Memory";
  181. char MountText[]        = "Mounted Devs";
  182. char PortsText[]        = "Ports";
  183. char ResidentsText[]    = "Residents";
  184. char ResourcesText[]    = "Resources";
  185. char ScreenModeText[]   = "ScreenMode";
  186. char SemaphoresText[]   = "Semaphores";
  187. char SystemText[]       = "System";           /*-*/
  188. char TasksText[]        = "Tasks";
  189. char TimerText[]        = "Timer";            /*-*/
  190. char VectorsText[]      = "Vectors";
  191. char WindowsText[]      = "Windows";
  192.  
  193. #define RB CHECKIT
  194. #define TG CHECKIT|MENUTOGGLE
  195.  
  196. const struct NewMenu menu_list[] =
  197. {
  198.    { NM_TITLE, "Project",  0,0,0,0},
  199.    { NM_ITEM,  "About...", "?",0,0,(APTR) ID_ABOUT},
  200.    { NM_ITEM,  NM_BARLABEL,0,0,0,0},
  201.    { NM_ITEM,  "Quit",     "Q",0,0,(APTR) ID_QUIT},
  202.  
  203.    { NM_TITLE, "List",     0,0,0,0},
  204.    { NM_ITEM,  AllocationsText,  "A",0,0,(APTR) ID_ALLOCATIONS},
  205.    { NM_ITEM,  AssignsText,      "G",0,0,(APTR) ID_ASSIGNS},
  206.    { NM_ITEM,  ClassesText,      "B",0,0,(APTR) ID_CLASSES},
  207.    { NM_ITEM,  CommoditiesText,  "K",0,0,(APTR) ID_COMMODITIES},
  208.    { NM_ITEM,  DevicesText,      "D",0,0,(APTR) ID_DEVICES},
  209.    { NM_ITEM,  ExpansionsText,   "X",0,0,(APTR) ID_EXPANSIONS},
  210.    { NM_ITEM,  FontsText,        "F",0,0,(APTR) ID_FONTS},
  211.    { NM_ITEM,  InputHandlersText,"H",0,0,(APTR) ID_INPUTHANDLER},
  212.    { NM_ITEM,  InterruptsText,   "I",0,0,(APTR) ID_INTERRUPTS},
  213.    { NM_ITEM,  LibrariesText,    "L",0,0,(APTR) ID_LIBRARIES},
  214.    { NM_ITEM,  LocksText,        "O",0,0,(APTR) ID_LOCKS},
  215.    { NM_ITEM,  LowMemoryText,    "J",0,0,(APTR) ID_LOWMEMORY},
  216.    { NM_ITEM,  MemoryText,       "M",0,0,(APTR) ID_MEMORY},
  217.    { NM_ITEM,  MountText,        "N",0,0,(APTR) ID_MOUNT},
  218.    { NM_ITEM,  PortsText,        "P",0,0,(APTR) ID_PORTS},
  219.    { NM_ITEM,  ResidentsText,    "R",0,0,(APTR) ID_RESIDENTS},
  220.    { NM_ITEM,  CommandsText,     "C",0,0,(APTR) ID_COMMANDS},
  221.    { NM_ITEM,  ResourcesText,    "U",0,0,(APTR) ID_RESOURCES},
  222.    { NM_ITEM,  ScreenModeText,   "Z",0,0,(APTR) ID_SCREENMODE},
  223.    { NM_ITEM,  SemaphoresText,   "S",0,0,(APTR) ID_SEMAPHORES},
  224.    { NM_ITEM,  SystemText,       "Y",0,0,(APTR) ID_SYSTEM},
  225.    { NM_ITEM,  TasksText,        "T",0,0,(APTR) ID_TASKS},
  226.    { NM_ITEM,  TimerText,        "E",0,0,(APTR) ID_TIMER},
  227.    { NM_ITEM,  VectorsText,      "V",0,0,(APTR) ID_VECTORS},
  228.    { NM_ITEM,  WindowsText,      "W",0,0,(APTR) ID_WINDOWS},
  229.  
  230.    { NM_TITLE, "Other",          0,0,0,0},
  231.    { NM_ITEM,  "Flush devices",  0,0,0,(APTR) ID_FLUSHDEVS},
  232.    { NM_ITEM,  "Flush fonts",    0,0,0,(APTR) ID_FLUSHFONTS},
  233.    { NM_ITEM,  "Flush libraries",0,0,0,(APTR) ID_FLUSHLIBS},
  234.    { NM_ITEM,  "Flush all",      ".",0,0,(APTR) ID_FLUSHALL},
  235.    { NM_ITEM,  NM_BARLABEL,      0,0,0,0},
  236.    { NM_ITEM,  "Clear reset vectors","!",0,0,(APTR) ID_CLEARRESET},
  237.  
  238.    { NM_END,   NULL,       0,0,0,0},
  239. };
  240.  
  241. /*********************************************************************
  242.                          Requester-Daten
  243. *********************************************************************/
  244.  
  245. /*********************************************************************
  246.                            WinFree-Handling
  247.    Die Abkopplung einiger Windows wird hiermit realisiert!
  248. *********************************************************************/
  249. struct WinFree *WinFree_ToDo;
  250. struct WinFlag *WinFlag_ToDo;
  251.  
  252. struct WinFree FirstWinFree = {
  253.    (APTR) NULL, (APTR) NULL, NULL,
  254.    &FirstWinFree, &FirstWinFree
  255. };
  256.  
  257. void RemoveWinFree (void) {
  258.    if (SingleDetailWinFree == WinFree_ToDo) {
  259.       SingleDetailWinFree = NULL;
  260.    }
  261.  
  262.    SetWindowClose (WinFree_ToDo->wf_Window,FALSE);
  263.    if (WinFree_ToDo->wf_Pool) tbDeletePool(WinFree_ToDo->wf_Pool);
  264.  
  265.    WinFree_ToDo->wf_Next->wf_Previous = WinFree_ToDo->wf_Previous;
  266.    WinFree_ToDo->wf_Previous->wf_Next = WinFree_ToDo->wf_Next;
  267.  
  268.    tbFreeVecPooled(GlobalPool, WinFree_ToDo);
  269. }
  270.  
  271. struct WinFree *AllocWinFree (void) {
  272.    struct WinFree *result;
  273.  
  274.    if (result = tbAllocVecPooled(GlobalPool, sizeof (struct WinFree))) {
  275.       result->wf_Next = &FirstWinFree;
  276.       result->wf_Previous = FirstWinFree.wf_Previous;
  277.       result->wf_Previous->wf_Next = result;
  278.       result->wf_Next->wf_Previous = result;
  279.    }
  280.    return (result);
  281. }
  282.  
  283. void FreeMemoryOfAllWinFrees (void) {
  284.    struct WinFree *lauf = FirstWinFree.wf_Next, *next;
  285.  
  286.    while (lauf != &FirstWinFree) {
  287.       next = lauf->wf_Next;
  288.  
  289.       if (lauf->wf_Pool) tbDeletePool(lauf->wf_Pool);
  290.       tbFreeVecPooled(GlobalPool, lauf);
  291.  
  292.       lauf = next;
  293.    }
  294. }
  295.  
  296. /*********************************************************************
  297.                                  Fail
  298.    Diese Routine wird zum Schluß des Programmes aufgerufen!
  299. *********************************************************************/
  300. static VOID fail1 (VOID) {
  301.    Forbid();
  302.    if (FindPort ("AMITCP")) {
  303.       Permit();
  304.       failtcp();
  305.    } else {
  306.       Permit();
  307.    }
  308.  
  309.    if (TimerIORequest) {
  310.       if (!timer2) {
  311.          if (timer_ticking) {
  312.             AbortIO ((struct IORequest *) TimerIORequest);
  313.             WaitIO ((struct IORequest *) TimerIORequest);
  314.          }
  315.          CloseDevice ((struct IORequest *) TimerIORequest);
  316.       }
  317.       DeleteIORequest(TimerIORequest);
  318.    }
  319.  
  320.    if (InputIORequest) {
  321.       if (!input) {
  322.          CloseDevice ((struct IORequest *) InputIORequest);
  323.       }
  324.       DeleteIORequest(InputIORequest);
  325.    }
  326.  
  327.    if (ScoutPort) {
  328.       if (ScoutPortAdded) RemPort (ScoutPort);
  329.       DeleteMsgPort(ScoutPort);
  330.    }
  331.  
  332.    if (prevdir) CurrentDir(prevdir);
  333.  
  334.    FreeLibraries();
  335.    FreeDevices();
  336.    FreeResources();
  337.  
  338.    FreeTasks();
  339.    FreePorts();
  340.    FreeCommands();
  341.  
  342.    FreeExpansions();
  343.    FreeMemory();
  344.    FreeResidents();
  345.  
  346.    FreeAssigns();
  347.    FreeLocks();
  348.    FreeMounts();
  349.  
  350.    FreeInputHandler();
  351.    FreeInterrupts();
  352.  
  353.    FreeFonts();
  354.    FreeSemaphores();
  355.    FreeWindows();
  356.  
  357.    FreeTimer();
  358.    FreeLowMemory();
  359.    FreeSMode();
  360.    FreeCx();
  361.    FFreeClass();
  362.    FreeSystem();
  363.  
  364.    tbDeletePool(GlobalPool);
  365.  
  366.    if (RexxSysBase) CloseLibrary ((struct Library *)RexxSysBase);
  367.    if (ExpansionBase) CloseLibrary ((struct Library *)ExpansionBase);
  368.    if (IdentifyBase) CloseLibrary (IdentifyBase);
  369.    if (CxBase) CloseLibrary (CxBase);
  370.    if (AslBase) CloseLibrary (AslBase);
  371.    if (DiskfontBase) CloseLibrary (DiskfontBase);
  372.    if (UtilityBase) CloseLibrary (UtilityBase);
  373.    if (IconBase) CloseLibrary (IconBase);
  374.    if (IntuitionBase) CloseLibrary ((struct Library *) IntuitionBase);
  375.    if (GfxBase) CloseLibrary ((struct Library *) GfxBase);
  376.    if (LayersBase) CloseLibrary (LayersBase);
  377. }
  378.  
  379. static VOID fail (VOID) {
  380.    if (cheattask) RemoveCheatTask();
  381.  
  382.    if (AP_Scout) {
  383.       struct DiskObject *dob = NULL;
  384.  
  385.       get(AP_Scout, MUIA_Application_DiskObject, &dob);
  386.       if (dob) FreeDiskObject(dob);
  387.  
  388.       MUI_DisposeObject (AP_Scout);
  389.       AP_Scout = NULL;
  390.    }
  391.  
  392.    FreeMemoryOfAllWinFrees();
  393.  
  394.    DeleteCustomClasses();
  395.  
  396.    if (MUIMasterBase) CloseLibrary (MUIMasterBase);
  397.  
  398.    fail1();
  399. }
  400.  
  401. struct Library *MyOpenLibrary (char *libname, ULONG version) {
  402.    struct   Library  *libbase;
  403.  
  404.    if (!(libbase = OpenLibrary(libname,version))) {
  405.       aprintf ("Failed to open %s version %ld!\n", libname, version);
  406.    }
  407.    return (libbase);
  408. }
  409.  
  410. /*********************************************************************
  411.                                  Init
  412.    Diese Routine wird am Beginn des Programmes aufgerufen!
  413. *********************************************************************/
  414. static int init1 (VOID) {
  415.    GfxBase = (struct GfxBase *) OpenLibrary (GRAPHICSNAME, MYLIBVERSION);
  416.    IntuitionBase = (struct IntuitionBase *) OpenLibrary ("intuition.library", MYLIBVERSION);
  417.    IconBase = OpenLibrary (ICONNAME, MYLIBVERSION);
  418.    UtilityBase = OpenLibrary (UTILITYNAME, MYLIBVERSION);
  419.  
  420.    if ((!GfxBase) || (!IntuitionBase) || (!IconBase) || (!UtilityBase))
  421.       return (FALSE);
  422.  
  423.    if (!(AslBase = MyOpenLibrary ("asl.library",MYLIBVERSION)))
  424.       return (FALSE);
  425.  
  426.    if (!(DiskfontBase = MyOpenLibrary ("diskfont.library", MYLIBVERSION)))
  427.       return (FALSE);
  428.  
  429.    IdentifyBase = OpenLibrary("identify.library", IDENTIFYVERSION);
  430.  
  431.    if (!(CxBase = MyOpenLibrary ("commodities.library", MYLIBVERSION)))
  432.       return (FALSE);
  433.  
  434.    if (!(ExpansionBase = (struct ExpansionBase *)MyOpenLibrary (EXPANSIONNAME, MYLIBVERSION)))
  435.       return (FALSE);
  436.  
  437.    if (!(RexxSysBase = (struct RxsLib *)MyOpenLibrary (RXSNAME, 0)))
  438.       return (FALSE);
  439.  
  440.    if (!(LayersBase = MyOpenLibrary ("layers.library", MYLIBVERSION)))
  441.       return (FALSE);
  442.  
  443.    GlobalPool = tbCreatePool(MEMF_CLEAR, 4096, 4096);
  444.  
  445.    if (tmpstr = tbAllocPooled(GlobalPool, MAXTEXTLENGTH + 1)) {
  446.       if (tmpstr2 = tbAllocPooled(GlobalPool, MAXTEXTLENGTH + 1)) {
  447.          //
  448.       } else {
  449.          return (FALSE);
  450.       }
  451.    } else {
  452.       return (FALSE);
  453.    }
  454.    myprocess = FindTask (NULL);
  455.    prevdir = CurrentDir (((struct Process *) myprocess)->pr_HomeDir);
  456.  
  457.    if (ScoutPort = CreateMsgPort()) {
  458.       ScoutPort->mp_Node.ln_Name = "scout.reply";
  459.       ScoutPort->mp_Node.ln_Pri = 1;
  460.  
  461.       TimerSignal = ScoutPort->mp_SigBit;
  462.  
  463.       AddPort (ScoutPort);
  464.       ScoutPortAdded = TRUE;
  465.  
  466.       if (InputIORequest = CreateIORequest(ScoutPort, sizeof(struct IOStdReq))) {
  467.          if (input = OpenDevice ("input.device", 0, (struct IORequest *) InputIORequest, 0)) {
  468.             aprintf ("Failed to open %s!\n", "input.device");
  469.             return (FALSE);
  470.          }
  471.       } else {
  472.          return (FALSE);
  473.       }
  474.  
  475.       if (TimerIORequest = CreateIORequest(ScoutPort, sizeof(struct timerequest))) {
  476.          if (timer2 = OpenDevice (TIMERNAME, 0, (struct IORequest *) TimerIORequest, 0)) {
  477.             aprintf ("Failed to open %s!\n", TIMERNAME);
  478.             return (FALSE);
  479.          }
  480.       } else {
  481.          return (FALSE);
  482.       }
  483.    } else {
  484.       return (FALSE);
  485.    }
  486.  
  487.    return (TRUE);
  488. }
  489.  
  490. static int init2 (VOID) {
  491.    if (!(MUIMasterBase = MyOpenLibrary (MUIMASTER_NAME,MUIVERSION)))
  492.       return (FALSE);
  493.  
  494.    if (!CreateCustomClasses())
  495.       return (FALSE);
  496.  
  497.    return (TRUE);
  498. }
  499.  
  500. /*********************************************************************
  501.                         Allerlei Funktionen
  502. *********************************************************************/
  503. void reverse (char s[]) {
  504.    int c, i, j;
  505.    for (i = 0, j = strlen(s)-1; i < j; i++, j--) {
  506.       c = s[i];
  507.       s[i] = s[j];
  508.       s[j] = c;
  509.    }
  510. }
  511.  
  512. char * ltob (ULONG n, int len) {
  513.    static char s[34];
  514.    int i;
  515.    i = 0;
  516.  
  517.    do {
  518.       s[i++] = n % 2 + '0';
  519.       n /= 2;
  520.    } while (--len > 0);
  521.    s[i] = '\0';
  522.    reverse (s);
  523.    return ((char *) &s);
  524. }
  525.  
  526. void healstring (char s[]) {
  527.    int i = 0;
  528.  
  529.    while (s[i++] != '\0') {
  530.       if ((s[i] > '\xfe') && (s[i] <= '\x7')) {
  531.          s[i] = '\0';
  532.       } else if ((s[i] > '\x7') && (s[i] <= '\x11')) {
  533.          s[i] = ' ';
  534.       }
  535.    }
  536. }
  537.  
  538. char * nonetest (char s[]) {
  539.    int i = 0;
  540.    char *none = "<none>";
  541.    unsigned char *t = (unsigned char *) s;
  542.  
  543.    if ((s <= (char *) 0x200) || (s[0] == 0))
  544.       return (none);
  545.  
  546.    while (t[i] != 0) {
  547.       if (!(((t[i] > 8) && (t[i] < 128)) || ((t[i] > 159) && (t[i] != 215) && (t[i] != 247) && (t[i] != 255))))
  548.          return (none);
  549.       i++;
  550.    }
  551.    return (s);
  552. }
  553.  
  554. int GetRamPointerCount (struct Library *lib) {
  555.    int   negsize;
  556.    int   count = 0, offset = 0;
  557.    APTR  value;
  558.    char  *adr;
  559.  
  560.    adr = (char *) lib;
  561.    negsize = lib->lib_NegSize;
  562.  
  563.    while (((offset += 6) <= negsize) && *(WORD *)(adr - offset)) {
  564.       if (*(WORD *)(adr - offset) == 0x4ef9) {
  565.          value = (APTR) *(LONG *)(adr - offset + 2);
  566.          if ((points2ram(value)) || (!value))
  567.             count += 1;
  568.       }
  569.    }
  570.  
  571.    if (offset >= negsize) {
  572.       return (count);
  573.    } else {
  574.       return (-1);
  575.    }
  576. }
  577.  
  578. /*********************************************************************
  579.                                Memory
  580. *********************************************************************/
  581.  
  582. /*********************************************************************
  583.                               Interrupts
  584. *********************************************************************/
  585.  
  586. /*********************************************************************
  587.                              InputHandler
  588. *********************************************************************/
  589.  
  590. /*********************************************************************
  591.                               Residents
  592. *********************************************************************/
  593.  
  594. /*********************************************************************
  595.                                Vectors
  596. *********************************************************************/
  597.  
  598. /*********************************************************************
  599.                                Allocations
  600. *********************************************************************/
  601.  
  602. /*********************************************************************
  603.                                System
  604. *********************************************************************/
  605.  
  606. /*********************************************************************
  607. *********************************************************************/
  608.  
  609. __asm __saveds int priority_callfunc(register __a1 char **contents) {
  610.    unsigned char  *pristring;
  611.    int pri=0,length;
  612.  
  613.    get (pritext3,MUIA_String_Contents,&pristring);
  614.  
  615.         if (((length = stcd_i (pristring,&pri)) == strlen (pristring)) && \
  616.                 (pri >= -128) && (pri <= 127)) {
  617.       set (SL_Priority,MUIA_Slider_Level,pri);
  618.       set (WI_Priority,MUIA_Window_ActiveObject,BT_PriorityOK);
  619.    } else {
  620.       set (WI_Priority,MUIA_Window_ActiveObject,pritext3);
  621.    }
  622.    
  623.    return (pri);
  624. }
  625.  
  626. struct Hook priority_callhook = {
  627.  {NULL, NULL},
  628.  (ULONG (* )())priority_callfunc,
  629.  NULL, NULL
  630. };
  631.  
  632. BOOL GetPriority (char *nodename, char *pritext, LONG *pri) {
  633.    BOOL  running = TRUE, result = FALSE;
  634.    LONG  oldpri;
  635.    ULONG signal;
  636.  
  637.    IsDec (pritext, &oldpri);
  638.  
  639.    WI_Priority = WindowObject,
  640.  
  641.    MUIA_Window_Title, "SCOUT: Change priority",
  642.    MUIA_Window_ID, MakeID('P','R','I','O'),
  643.    WindowContents, VGroup,
  644.       Child, MyVSpace(2),
  645.       Child, pritext1 = MyTextObject(),
  646.       Child, MyVSpace(2),
  647.       Child, SL_Priority = SliderObject,
  648.          MUIA_Slider_Min, -128,
  649.          MUIA_Slider_Max, 127,
  650.          MUIA_Slider_Level, 0,
  651.          MUIA_Slider_Quiet, TRUE,
  652.          MUIA_FixHeightTxt, " ",
  653.       End,
  654.       Child, MyVSpace(2),
  655.       Child, HGroup, MUIA_Group_SameWidth, TRUE,
  656.          Child, HGroup,
  657.             Child, MyLabel2 ("Min:"),
  658.             Child, MyTextObject3(ESC "c -128 "), 
  659.          End,
  660.          Child, HGroup,
  661.             Child, MyLabel2 ("Max:"),
  662.             Child, MyTextObject3(ESC "c127"), 
  663.          End,
  664.          Child, HGroup,
  665.             Child, MyLabel2 ("Old:"),
  666.             Child, pritext2 = MyTextObject(), 
  667.          End,
  668.          Child, HGroup,
  669.             Child, MyLabel2 ("New:"),
  670.             Child, pritext3 = StringObject,
  671.                MUIA_String_BufferPos, 1,
  672.                MUIA_String_Accept , "-0123456879",
  673.                MUIA_String_Integer, oldpri,
  674.                MUIA_String_MaxLen, 5, StringFrame,
  675.             End,
  676.          End,
  677.       End,
  678.       Child, MyVSpace(2),
  679.       Child, HGroup, MUIA_Group_SameWidth, TRUE,
  680.          Child, BT_PriorityOK     = KeyButtonA (OKText    ,ID_PRIORITYOK),
  681.          Child, BT_PriorityCancel = KeyButtonA (CancelText,ID_PRIORITYEXIT),
  682.       End,
  683.    End, End;
  684.  
  685.    if (WI_Priority) {
  686.       MySetContents (pritext1, ESC "c Please select a new priority for \n'%s'! ", nodename);
  687.       MySetContents (pritext2, ESC "c%ld",oldpri);
  688.       set (SL_Priority,MUIA_Slider_Level,oldpri);
  689.       set (pritext3,MUIA_Text_Contents,tmpstr);
  690.  
  691.       ApplicationSleep();
  692.  
  693.       DoMethod (AP_Scout,OM_ADDMEMBER,WI_Priority);
  694.       DoMethod (WI_Priority,MUIM_Window_SetCycleChain,SL_Priority,pritext3,BT_PriorityCancel,BT_PriorityOK,NULL);
  695.       SetCloseRequest (WI_Priority,(int) ID_PRIORITYEXIT);
  696.  
  697.       DoMethod (SL_Priority,MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,pritext3,4,MUIM_SetAsString,MUIA_String_Contents,"%ld",MUIV_TriggerValue);
  698.       DoMethod (pritext3,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,pritext3,3,MUIM_CallHook,&priority_callhook,MUIV_TriggerValue);
  699.  
  700.       SetWindowOpen (WI_Priority,SL_Priority,FALSE);
  701.  
  702.       while (running) {
  703.          switch (DoMethod(AP_Scout,MUIM_Application_Input,&signal)) {
  704.             case ID_PRIORITYOK:
  705.                get (SL_Priority,MUIA_Slider_Level,pri);
  706.                result = TRUE;
  707.                running = FALSE;
  708.                break;
  709.  
  710.             case ID_PRIORITYEXIT:
  711.                running = FALSE;
  712.                break;
  713.  
  714.             default:
  715.                break;
  716.          }
  717.          if (running && signal)
  718.             Wait (signal);
  719.       }
  720.  
  721.       SetWindowClose (WI_Priority,FALSE);
  722.       AwakeApplication();
  723.  
  724.       DoMethod (AP_Scout,OM_REMMEMBER,WI_Priority);
  725.       MUI_DisposeObject (WI_Priority);
  726.       WI_Priority = NULL;
  727.    }
  728.    return (result);
  729. }
  730.  
  731. BOOL GetSignal (char *taskname, char *waitsignal, char *resultstring) {
  732.    BOOL  running = TRUE, result = FALSE;
  733.    LONG  signal;
  734.    char  *textptr;
  735.  
  736.    WI_Signal = WindowObject,
  737.  
  738.    MUIA_Window_Title, "SCOUT: Send signal",
  739.    MUIA_Window_ID, MakeID('S','E','N','D'),
  740.    WindowContents, VGroup,
  741.       Child, MyVSpace(2),
  742.       Child, sigtext1 = MyTextObject(),
  743.       Child, MyVSpace(2),
  744.       Child, HGroup, MUIA_Group_SameWidth, TRUE,
  745.          Child, HGroup,
  746.             Child, KeyLabel("Signal:", 's'),
  747.             Child, sigtext2 = StringObject,
  748.                MUIA_ControlChar, 's',
  749.                MUIA_String_MaxLen, 10, StringFrame,
  750.                MUIA_String_EditHook, &hexstring_edithook,
  751.             End,
  752.          End,
  753.          Child, HGroup,
  754.             Child, MyLabel ("SigWait:"),
  755.             Child, sigtext3 = MyTextObject(), 
  756.          End,
  757.       End,
  758.       Child, MyVSpace(2),
  759.       Child, HGroup, MUIA_Group_SameWidth, TRUE,
  760.          Child, BT_SignalOK     = KeyButtonA (OKText    ,ID_SIGNALOK),
  761.          Child, BT_SignalCancel = KeyButtonA (CancelText,ID_SIGNALEXIT),
  762.       End,
  763.    End, End;
  764.  
  765.    if (WI_Signal) {
  766.       MySetContents (sigtext1, ESC "c Please select the signal for \n'%s'! ", taskname);
  767.       set (sigtext2, MUIA_String_Contents, waitsignal);
  768.       MySetContents (sigtext3, ESC "c%s", waitsignal);
  769.  
  770.       ApplicationSleep();
  771.  
  772.       DoMethod (AP_Scout,OM_ADDMEMBER,WI_Signal);
  773.       DoMethod (WI_Signal,MUIM_Window_SetCycleChain,sigtext2,BT_SignalOK,BT_SignalCancel,NULL);
  774.       SetCloseRequest (WI_Signal,(int) ID_SIGNALEXIT);
  775.  
  776.       SetWindowOpen (WI_Signal,sigtext2,FALSE);
  777.  
  778.       while (running) {
  779.          switch (DoMethod(AP_Scout,MUIM_Application_Input,&signal)) {
  780.             case ID_SIGNALOK:
  781.                get (sigtext2,MUIA_String_Contents,&textptr);
  782.                strcpy (resultstring, textptr);
  783.                running = FALSE;
  784.                result = TRUE;
  785.                break;
  786.  
  787.             case ID_SIGNALEXIT:
  788.                running = FALSE;
  789.                break;
  790.  
  791.             default:
  792.                break;
  793.          }
  794.          if (running && signal)
  795.             Wait (signal);
  796.       }
  797.  
  798.       SetWindowClose (WI_Signal,FALSE);
  799.       AwakeApplication();
  800.  
  801.       DoMethod (AP_Scout,OM_REMMEMBER,WI_Signal);
  802.       MUI_DisposeObject (WI_Signal);
  803.       WI_Signal = NULL;
  804.    }
  805.    return (result);
  806. }
  807.  
  808. /*********************************************************************
  809.                              LowMemory
  810. *********************************************************************/
  811.  
  812. /*********************************************************************
  813.                              Timer
  814. *********************************************************************/
  815.  
  816. /*********************************************************************
  817.  BEGIN:                        MAIN
  818. *********************************************************************/
  819.  
  820. __asm __saveds ULONG main (register __a0 struct WBStartup *msg) {
  821.    BOOL  RETURN_FLAG = FALSE;
  822.    ULONG RETURN_CODE = RETURN_OK;
  823.    struct Library *miamilib = NULL;
  824.  
  825.    if (! init1()) {
  826.       fail1();
  827.       return (RETURN_FAIL);
  828.    }
  829.  
  830.    if ((opts.User || opts.Password) && (! opts.Host)) {
  831.       aprintf ("You didn't specify the HOST!\n");
  832.       RETURN_CODE = RETURN_FAIL;
  833.       RETURN_FLAG = TRUE;
  834.  
  835.    } else if (opts.Host) {
  836.       Forbid();
  837.       if (FindPort ("AMITCP") != NULL || (miamilib = OpenLibrary("miami.library",0L)) != NULL) {
  838.          Permit();
  839.          if(miamilib) CloseLibrary(miamilib);
  840.          if (opts.Command) {
  841.             RETURN_CODE = netshellclient();
  842.             RETURN_FLAG = TRUE;
  843.          } else if (! (clientstate = ConnectToServer())) {
  844.             RETURN_CODE = RETURN_FAIL;
  845.             RETURN_FLAG = TRUE;
  846.          }
  847.       } else {
  848.          Permit();
  849.          aprintf ("You have to start AmiTCP 4.0+ first!\n");
  850.          RETURN_CODE = RETURN_FAIL;
  851.          RETURN_FLAG = TRUE;
  852.       }
  853.  
  854.    } else if (opts.Command) {
  855.       shellstate = TRUE;
  856.       RETURN_CODE = ExecuteCommand (opts.Command);
  857.       RETURN_FLAG = TRUE;
  858.  
  859.    } else {
  860.       Forbid();
  861.       if (FindPort ("AMITCP") && isNetCall()) {
  862.          Permit();
  863.          RETURN_CODE = netdaemon();
  864.          RETURN_FLAG = TRUE;
  865.       } else {
  866.          Permit();
  867.       }
  868.    }
  869.  
  870.    if (RETURN_FLAG) {
  871.       fail1();
  872.       return (RETURN_CODE);
  873.    }
  874.  
  875.    if (! init2()) {
  876.       fail();
  877.       return (RETURN_FAIL);
  878.    }
  879.  
  880.    if ((opts.CpuDisplay) && (! clientstate)) {
  881.       updatetimestate = (ULONG) *opts.CpuDisplay;
  882.    }
  883.  
  884.    if (opts.SortLibrariesType)
  885.       libsortstate = *opts.SortLibrariesType;
  886.    liblist_cmphook_ptr = LibSortList[libsortstate];
  887.  
  888.    if (opts.SortDevicesType)
  889.       devsortstate = *opts.SortDevicesType;
  890.    devlist_cmphook_ptr = LibSortList[devsortstate];
  891.  
  892.    if (opts.SortResourcesType)
  893.       ressortstate = *opts.SortResourcesType;
  894.    reslist_cmphook_ptr = LibSortList[ressortstate];
  895.  
  896.    if (opts.SortTasksType)
  897.       tasksortstate = *opts.SortTasksType;
  898.    tasklist_cmphook_ptr = TaskSortList[tasksortstate];
  899.  
  900.    if (opts.SortPortsType)
  901.       portsortstate = *opts.SortPortsType;
  902.    portlist_cmphook_ptr = PortSortList[portsortstate];
  903.  
  904.    if (opts.SortCommandsType)
  905.       comsortstate = *opts.SortCommandsType;
  906.    comlist_cmphook_ptr = ComSortList[comsortstate];
  907.  
  908.    if (opts.SortAssignsType)
  909.       asssortstate = *opts.SortAssignsType;
  910.    asslist_cmphook_ptr = AssSortList[asssortstate];
  911.  
  912.    if (opts.SortLocksType)
  913.       locksortstate = *opts.SortLocksType;
  914.    locklist_cmphook_ptr = LockSortList[locksortstate];
  915.  
  916.    if (opts.SortCommoditiesType)
  917.       cxsortstate = *opts.SortCommoditiesType;
  918.    cxlist_cmphook_ptr = CxSortList[cxsortstate];
  919.  
  920.    if (opts.SortClassesType)
  921.       classsortstate = *opts.SortClassesType;
  922.    classlist_cmphook_ptr = ClassSortList[classsortstate];
  923.  
  924.    if (opts.SortScreenmodeType)
  925.       smodesortstate = *opts.SortScreenmodeType;
  926.    smodelist_cmphook_ptr = SModeSortList[smodesortstate];
  927.  
  928.    if ((opts.IntervalTime) && (IsReal (opts.IntervalTime))) {
  929.       if (strlen (opts.IntervalTime) <= 6) {
  930.          cpuinterval_callfunc (&opts.IntervalTime);
  931.          strcpy (updatetimetext, opts.IntervalTime);
  932.       }
  933.    }
  934.  
  935.    if (! GetApplication()) {
  936.       aprintf ("Failed to create application!\n");
  937.       fail();
  938.       return (RETURN_FAIL);
  939.    }
  940.  
  941.    Forbid();
  942.    if (portname = FindMyARexxPort ("SCOUT")) {
  943.       myarexxport = FindPort (portname);
  944.    } else {
  945.       portname = " < ERROR > ";
  946.       myarexxport = NULL;
  947.    }
  948.  
  949.    if ((opts.PortName) && (myarexxport)) {
  950.       portname = opts.PortName;
  951.       myarexxport->mp_Node.ln_Name = opts.PortName;
  952.    }
  953.    Permit();
  954.  
  955.    if (opts.Iconified) {
  956.       set (AP_Scout, MUIA_Application_Iconified, TRUE);
  957.    }
  958. /*
  959. ** Everything's ready, lets launch the application. We will
  960. ** open the master window now at this old position.
  961. */
  962.  
  963.    DoMethod (AP_Scout,MUIM_Application_Load,MUIV_Application_Load_ENV);
  964.  
  965.    SetWindowOpen (WI_Main,NULL,FALSE);
  966.  
  967. /*
  968. ** Now the ARexx startup script will be started. Herewith it's
  969. ** possible to open window at the beginning.
  970. */
  971.  
  972.    if (opts.Startup) {
  973.       BPTR startuplock;
  974.       if (startuplock = Lock (opts.Startup, ACCESS_READ)) {
  975.          UnLock (startuplock);
  976.          if (! SendStartupMsg ("REXX", opts.Startup, TRUE))
  977.             aprintf ("Failed to send port 'REXX' scriptname '%s'!\n", opts.Startup);
  978.       } else {
  979.          if (! SendStartupMsg (myarexxport->mp_Node.ln_Name, opts.Startup, FALSE))
  980.             aprintf ("Failed to send port '%s' message \"%s\"!\n", myarexxport->mp_Node.ln_Name, opts.Startup);
  981.       }
  982.    }
  983.  
  984. /*
  985. ** This is the main loop. As you can see, it does just nothing.
  986. ** Everything is handled by MUI, no work for the programmer.
  987. */
  988.  
  989.    {
  990.       BOOL     running = TRUE;
  991.       LONG     pos, id; // für MultipleLockSelect
  992.       ULONG    signal, received = 0;
  993.       STRPTR   cxhelp;
  994.       struct   ListEntry      *entryp = 0;
  995.       struct   Task           *tmptask;
  996.       struct   Node           *node;
  997.       ULONG    reid;
  998.  
  999.       while (running) {
  1000.          reid = DoMethod(AP_Scout,MUIM_Application_Input,&signal);
  1001.          if(reid==MUIV_Application_ReturnID_Quit)
  1002.            running = FALSE;
  1003.  
  1004.          else if((reid>ID_FIRSTID) && (reid<ID_LASTID)) switch (reid) {
  1005.             case ID_LIBPRINT:
  1006.                PrintLibraries (NULL);
  1007.                break;
  1008.  
  1009.             case ID_LIBRARIES:
  1010.             case ID_LIBUPDATE:
  1011.                LibrariesWindow (TRUE);
  1012.                break;
  1013.  
  1014.             case ID_LIBREMOVE:
  1015.                if (entryp = GetActiveEntry (liblist)) {
  1016.                   if (MyRequest ("Yes|No", "Do you really want to remove\n'%s'?", ((struct LibEntry *) entryp)->lib_name)) {
  1017.                      MyDoCommand ("RemoveLibrary \"%s\"", ((struct LibEntry *) entryp)->lib_name);
  1018.                      ShowLibraries ();
  1019.                   }
  1020.                }
  1021.                break;
  1022.  
  1023.             case ID_LIBCLOSE:
  1024.                if (entryp = GetActiveEntry (liblist)) {
  1025.                   int tmpint;
  1026.                   long tmplong;
  1027.  
  1028.                   if ((IsDec (((struct LibEntry *) entryp)->lib_ocnt, &tmplong)) && (tmplong)) {
  1029.                      if (tmpint = MyRequest ("Once|All|Cancel", "Do you really want to close\n '%s'?", ((struct LibEntry *) entryp)->lib_name)) {
  1030.                         if (tmpint == 1) {
  1031.                            MyDoCommand ("CloseLibrary \"%s\"", ((struct LibEntry *) entryp)->lib_name);
  1032.                            tmplong--;
  1033.                         } else {
  1034.                            while (tmplong) {
  1035.                               if (! MyDoCommand ("CloseLibrary \"%s\"", ((struct LibEntry *) entryp)->lib_name)) {
  1036.                                  break;
  1037.                               }
  1038.                               tmplong--;
  1039.                            }
  1040.                         }
  1041.                         _sprintf (((struct LibEntry *) entryp)->lib_ocnt, "%3ld ", tmplong);
  1042.                         RedrawActiveEntry (liblist);
  1043.                      }
  1044.                   } else {
  1045.                      MyRequest ("Continue", "The OpenCount of \'%s\' is already zero!", ((struct LibEntry *) entryp)->lib_name);
  1046.                   }
  1047.                }
  1048.                break;
  1049.  
  1050.             case ID_LIBPRIORITY:
  1051.                if (entryp = GetActiveEntry (liblist)) {
  1052.                   LONG tmppri;
  1053.  
  1054.                   if (GetPriority (((struct LibEntry *) entryp)->lib_name, ((struct LibEntry *) entryp)->lib_pri, &tmppri)) {
  1055.                      if (MyDoCommand ("SetPriority LIBRARY \"%s\" %ld", ((struct LibEntry *) entryp)->lib_name, tmppri)) {
  1056.                         _sprintf (((struct LibEntry *) entryp)->lib_pri, "%4ld ", tmppri);
  1057.                      }
  1058.                      ShowLibraries ();
  1059.                   }
  1060.                }
  1061.                break;
  1062.  
  1063.             case ID_LIBFUNCTIONS:
  1064.                if (node = HandleNodeDetails (liblist, "library"))
  1065.                   GetLDRFctList ((struct Library *) node,'L');
  1066.                break;
  1067.  
  1068.             case ID_LIBMORE:
  1069.                if (node = HandleNodeDetails (liblist, "library"))
  1070.                   GetLibMore ((struct Library *) node);
  1071.                break;
  1072.  
  1073.             case ID_LIBEXIT:
  1074.                LibrariesWindow (FALSE);
  1075.                break;
  1076.  
  1077.             case ID_LIBLV_ACTIVE:
  1078.                if (entryp = GetActiveEntry (liblist)) {
  1079.                   MySetContents (libtext, "%s \"%-.30s\"", ((struct LibEntry *) entryp)->lib_address, ((struct LibEntry *) entryp)->lib_name);
  1080.  
  1081.                   set (BT_LibRemove, MUIA_Disabled, FALSE);
  1082.                   set (BT_LibClose, MUIA_Disabled, FALSE);
  1083.                   set (BT_LibPriority, MUIA_Disabled, FALSE);
  1084.  
  1085.                   if (! clientstate) {
  1086.                      set (BT_LibMore, MUIA_Disabled, FALSE);
  1087.                      set (BT_LibFunctions, MUIA_Disabled, FALSE);
  1088.                   }
  1089.                }
  1090.                break;
  1091.  
  1092.             case ID_DEVPRINT:
  1093.                PrintDevices (NULL);
  1094.                break;
  1095.  
  1096.             case ID_DEVICES:
  1097.             case ID_DEVUPDATE:
  1098.                DevicesWindow (TRUE);
  1099.                break;
  1100.  
  1101.             case ID_DEVREMOVE:
  1102.                if (entryp = GetActiveEntry (devlist)) {
  1103.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%s\'?", ((struct LibEntry *) entryp)->lib_name)) {
  1104.                      MyDoCommand ("RemoveDevice \"%s\"", ((struct LibEntry *) entryp)->lib_name);
  1105.                      ShowDevices ();
  1106.                   }
  1107.                }
  1108.                break;
  1109.  
  1110.             case ID_DEVPRIORITY:
  1111.                if (entryp = GetActiveEntry (devlist)) {
  1112.                   LONG tmppri;
  1113.  
  1114.                   if (GetPriority (((struct LibEntry *) entryp)->lib_name, ((struct LibEntry *) entryp)->lib_pri, &tmppri)) {
  1115.                      if (MyDoCommand ("SetPriority DEVICE \"%s\" %ld", ((struct LibEntry *) entryp)->lib_name, tmppri)) {
  1116.                         _sprintf (((struct LibEntry *) entryp)->lib_pri, "%4ld ", tmppri);
  1117.                      }
  1118.                      ShowDevices ();
  1119.                   }
  1120.                }
  1121.                break;
  1122.  
  1123.             case ID_DEVFUNCTIONS:
  1124.                if (node = HandleNodeDetails (devlist, "device"))
  1125.                   GetLDRFctList ((struct Library *) node,'D');
  1126.                break;
  1127.  
  1128.             case ID_DEVMORE:
  1129.                if (node = HandleNodeDetails (devlist, "device"))
  1130.                   GetDevMore ((struct Library *) node);
  1131.                break;
  1132.  
  1133.             case ID_DEVEXIT:
  1134.                DevicesWindow (FALSE);
  1135.                break;
  1136.  
  1137.             case ID_DEVLV_ACTIVE:
  1138.                if (entryp = GetActiveEntry (devlist)) {
  1139.                   MySetContents (devtext, "%s \"%s\"", ((struct LibEntry *) entryp)->lib_address, ((struct LibEntry *) entryp)->lib_name);
  1140.  
  1141.                   set (BT_DevRemove, MUIA_Disabled, FALSE);
  1142.                   set (BT_DevPriority, MUIA_Disabled, FALSE);
  1143.  
  1144.                   if (! clientstate) {
  1145.                      set (BT_DevMore, MUIA_Disabled, FALSE);
  1146.                      set (BT_DevFunctions, MUIA_Disabled, FALSE);
  1147.                   }
  1148.                }
  1149.                break;
  1150.  
  1151.             case ID_RESPRINT:
  1152.                PrintResources (NULL);
  1153.                break;
  1154.  
  1155.             case ID_RESOURCES:
  1156.             case ID_RESUPDATE:
  1157.                ResourcesWindow (TRUE);
  1158.                break;
  1159.  
  1160.             case ID_RESREMOVE:
  1161.                if (entryp = GetActiveEntry (reslist)) {
  1162.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%s\'?", ((struct LibEntry *) entryp)->lib_name)) {
  1163.                      MyDoCommand ("RemoveResource \"%s\"", ((struct LibEntry *) entryp)->lib_name);
  1164.                      ShowResources ();
  1165.                   }
  1166.                }
  1167.                break;
  1168.  
  1169.             case ID_RESPRIORITY:
  1170.                if (entryp = GetActiveEntry (reslist)) {
  1171.                   LONG tmppri;
  1172.  
  1173.                   if (GetPriority (((struct LibEntry *) entryp)->lib_name, ((struct LibEntry *) entryp)->lib_pri, &tmppri)) {
  1174.                      if (MyDoCommand ("SetPriority RESOURCE \"%s\" %ld", ((struct LibEntry *) entryp)->lib_name, tmppri)) {
  1175.                         _sprintf (((struct LibEntry *) entryp)->lib_pri, "%4ld ", tmppri);
  1176.                      }
  1177.                      ShowResources ();
  1178.                   }
  1179.                }
  1180.                break;
  1181.  
  1182.             case ID_RESFUNCTIONS:
  1183.                if (node = HandleNodeDetails (reslist, "resource"))
  1184.                   GetLDRFctList ((struct Library *) node,'R');
  1185.                break;
  1186.  
  1187.             case ID_RESMORE:
  1188.                if (node = HandleNodeDetails (reslist, "resource"))
  1189.                   GetResMore ((struct Library *) node);
  1190.                break;
  1191.  
  1192.             case ID_RESEXIT:
  1193.                ResourcesWindow (FALSE);
  1194.                break;
  1195.  
  1196.             case ID_RESLV_ACTIVE:
  1197.                if (entryp = GetActiveEntry (reslist)) {
  1198.                   MySetContents (restext, "%s \"%s\"", ((struct LibEntry *) entryp)->lib_address, ((struct LibEntry *) entryp)->lib_name);
  1199.  
  1200.                   set (BT_ResRemove, MUIA_Disabled, FALSE);
  1201.                   set (BT_ResPriority, MUIA_Disabled, FALSE);
  1202.  
  1203.                   if (! clientstate) {
  1204.                      set (BT_ResMore, MUIA_Disabled, FALSE);
  1205.                      set (BT_ResFunctions, MUIA_Disabled, FALSE);
  1206.                   }
  1207.                }
  1208.                break;
  1209.  
  1210.             case ID_TASKPRINT:
  1211.                PrintTasks (NULL);
  1212.                break;
  1213.  
  1214.             case ID_TASKS:
  1215.             case ID_TASKUPDATE:
  1216.                TasksWindow (TRUE);
  1217.                break;
  1218.  
  1219.             case ID_CPUUSAGE:
  1220.                if (! clientstate) {
  1221.                   CheckCPUUsage();
  1222.                }
  1223.                break;
  1224.  
  1225.             case ID_TASKREMOVE:
  1226.                if (entryp = GetActiveEntry (tasklist)) {
  1227.                   if (MyRequest ("Yes|No", "Do you really want to remove\ntask \'%s\'?", ((struct TaskEntry *) entryp)->ts_name)) {
  1228.                      BOOL withports;
  1229.  
  1230.                      withports = MyRequest("Yes|No", "Also remove ports, windows, etc. allocated by task\n\'%s\'?", ((struct TaskEntry *) entryp)->ts_name);
  1231.  
  1232.                      if (MyDoCommand ("RemoveTask %s", ((struct TaskEntry *) entryp)->ts_address, withports)) {
  1233.                         RemoveActiveEntry (tasklist);
  1234.                         SetCountText (taskcount, --taskcnt);
  1235.                      } else {
  1236.                         ShowTasks();
  1237.                      }
  1238.                   }
  1239.                }
  1240.                break;
  1241.  
  1242.             case ID_TASKFREEZE:
  1243.                if (entryp = GetActiveEntry (tasklist)) {
  1244.                   if (MyDoCommand ("FreezeTask %s", ((struct TaskEntry *) entryp)->ts_address)) {
  1245.                      strcpy (((struct TaskEntry *) entryp)->ts_state, "frozen");
  1246.                      RedrawActiveEntry (tasklist);
  1247.                   } else {
  1248.                      ShowTasks();
  1249.                   }
  1250.                }
  1251.                break;
  1252.  
  1253.             case ID_TASKACTIVATE:
  1254.                if (entryp = GetActiveEntry (tasklist)) {
  1255.                   if (MyDoCommand ("ActivateTask %s", ((struct TaskEntry *) entryp)->ts_address)) {
  1256.                      strcpy (((struct TaskEntry *) entryp)->ts_state, "wait");
  1257.                      RedrawActiveEntry (tasklist);
  1258.                   } else {
  1259.                      ShowTasks();
  1260.                   }
  1261.                }
  1262.                break;
  1263.  
  1264.             case ID_TASKSIGNAL:
  1265.                if (entryp = GetActiveEntry (tasklist)) {
  1266.                   char tmptext[12];
  1267.  
  1268.                   if (GetSignal (((struct TaskEntry *) entryp)->ts_name, ((struct TaskEntry *) entryp)->ts_sigwait, tmptext)) {
  1269.                      if (MyDoCommand ("SignalTask %s %s", ((struct TaskEntry *) entryp)->ts_address, tmptext)) {
  1270.                         Delay (25);
  1271.                         RedrawActiveEntry (tasklist);
  1272.                      } else {
  1273.                         ShowTasks();
  1274.                      }
  1275.                   }
  1276.                }
  1277.                break;
  1278.  
  1279.             case ID_TASKBREAK:
  1280.                if (entryp = GetActiveEntry (tasklist)) {
  1281.                   if (MyDoCommand ("BreakTask %s", ((struct TaskEntry *) entryp)->ts_address)) {
  1282.                      Delay (25);
  1283.                      RedrawActiveEntry (tasklist);
  1284.                   } else {
  1285.                      ShowTasks();
  1286.                   }
  1287.                }
  1288.                break;
  1289.  
  1290.             case ID_TASKPRIORITY:
  1291.                if (entryp = GetActiveEntry (tasklist)) {
  1292.                   long tmppri = 0;
  1293.  
  1294.                   if (GetPriority (((struct TaskEntry *) entryp)->ts_name, ((struct TaskEntry *) entryp)->ts_pri, &tmppri)) {
  1295.                      if (MyDoCommand ("SetTaskPri %s %ld", ((struct TaskEntry *) entryp)->ts_address, tmppri)) {
  1296.                         _sprintf (((struct TaskEntry *) entryp)->ts_pri, "%4ld ", tmppri);
  1297.                         RedrawActiveEntry (tasklist);
  1298.                      } else {
  1299.                         ShowTasks();
  1300.                      }
  1301.                   }
  1302.                }
  1303.                break;
  1304.  
  1305.             case ID_TASKMORE:
  1306.                if (entryp = GetActiveEntry (tasklist)) {
  1307.                   Forbid();
  1308.                   if (tmptask = MyFindTask (((struct TaskEntry *) entryp)->ts_address)) {
  1309.                      if (((struct Node *) tmptask)->ln_Type == NT_PROCESS) {
  1310.                         GetProcessMore ((struct Process *) tmptask);
  1311.                      } else {
  1312.                         GetTaskMore ((struct Task *) tmptask);
  1313.                      }
  1314.                      Permit();
  1315.                   } else {
  1316.                      Permit();
  1317.                      MyRequest ("Continue", "Sorry, can't find that %s!", "task");
  1318.                      ShowTasks();
  1319.                   }
  1320.                }
  1321.                break;
  1322.  
  1323.             case ID_TASKEXIT:
  1324.                TasksWindow (FALSE);
  1325.                break;
  1326.  
  1327.             case ID_TASKLV_ACTIVE:
  1328.                if (entryp = GetActiveEntry (tasklist)) {
  1329.                   MySetContentsHealed (tasktext, "%s \"%s\"", ((struct TaskEntry *) entryp)->ts_address, ((struct TaskEntry *) entryp)->ts_name);
  1330.                   set (BT_TaskRemove, MUIA_Disabled, FALSE);
  1331.                   set (BT_TaskFreeze, MUIA_Disabled, FALSE);
  1332.                   set (BT_TaskActivate, MUIA_Disabled, FALSE);
  1333.                   set (BT_TaskPriority, MUIA_Disabled, FALSE);
  1334.                   set (BT_TaskSignal, MUIA_Disabled, FALSE);
  1335.                   set (BT_TaskBreak, MUIA_Disabled, FALSE);
  1336.  
  1337.                   if (! clientstate) {
  1338.                      set (BT_TaskMore, MUIA_Disabled, FALSE);
  1339.                   }
  1340.                }
  1341.                break;
  1342.  
  1343.             case ID_CXPRINT:
  1344.                PrintCx (NULL);
  1345.                break;
  1346.  
  1347.             case ID_COMMODITIES:
  1348.             case ID_CXUPDATE:
  1349.                CxWindow (TRUE);
  1350.                break;
  1351.  
  1352.             case ID_CXREMOVE:
  1353.                if (entryp = GetActiveEntry (cxlist)) {
  1354.                   if (MyRequest ("Yes|No", "Do you really want to remove\ncommodity \'%s\'?", ((struct CxEntry *) entryp)->cxe_name)) {
  1355.                      if (MyDoCommand ("RemoveCx %s", ((struct CxEntry *) entryp)->cxe_address)) {
  1356.                         RemoveActiveEntry (cxlist);
  1357.                         SetCountText (cxcount, --cxcnt);
  1358.                      } else {
  1359.                         ShowCx();
  1360.                      }
  1361.                   }
  1362.                }
  1363.                break;
  1364.  
  1365.             case ID_CXPRIORITY:
  1366.                if (entryp = GetActiveEntry (cxlist)) {
  1367.                   long tmppri = 0;
  1368.  
  1369.                   if (GetPriority (((struct CxEntry *) entryp)->cxe_name, ((struct CxEntry *) entryp)->cxe_pri, &tmppri)) {
  1370.                      if (MyDoCommand ("SetCxPri %s %ld", ((struct CxEntry *) entryp)->cxe_address, tmppri)) {
  1371.                         _sprintf (((struct CxEntry *) entryp)->cxe_pri, "%4ld ", tmppri);
  1372.                         RedrawActiveEntry (cxlist);
  1373.                      } else {
  1374.                         ShowCx();
  1375.                      }
  1376.                   }
  1377.                }
  1378.                break;
  1379.  
  1380.             case ID_CXMORE:
  1381.                if (entryp = GetActiveEntry (cxlist))
  1382.                   GetCxMore((struct MyCxObj *) ((struct CxEntry *)entryp)->cxe_adr);
  1383.                break;
  1384.  
  1385.             case ID_CXEXIT:
  1386.                CxWindow (FALSE);
  1387.                break;
  1388.  
  1389.             case ID_CXAPPEAR:
  1390.                cxhelp = "Appear";
  1391.                goto cx_setup;
  1392.             case ID_CXDISAPPEAR:
  1393.                cxhelp = "Disappear";
  1394.                goto cx_setup;
  1395.             case ID_CXENABLE:
  1396.                cxhelp = "Enable";
  1397.                goto cx_setup;
  1398.             case ID_CXDISABLE:
  1399.                cxhelp = "Disable";
  1400.                goto cx_setup;
  1401.             case ID_CXKILL:
  1402.                cxhelp = "Kill";
  1403.                goto cx_setup;
  1404.             case ID_CXLISTCHG:
  1405.                cxhelp = "ListChg";
  1406.                goto cx_setup;
  1407.             case ID_CXUNIQUE:
  1408.                cxhelp = "Unique";
  1409. cx_setup:
  1410.                if (entryp = GetActiveEntry (cxlist)) {
  1411.                   MyDoCommand ("Cx%s \"%s\"", cxhelp, ((struct CxEntry *) entryp)->cxe_name);
  1412.                   Delay(20);
  1413.                   CxWindow (TRUE);
  1414.                }
  1415.                break;
  1416.  
  1417.             case ID_CXLV_ACTIVE:
  1418.                if (entryp = GetActiveEntry (cxlist)) {
  1419.                   struct CxEntry *cxe = (struct CxEntry *)entryp;
  1420.  
  1421.                   MySetContentsHealed (cxtext, "%s \"%s\"", cxe->cxe_address, cxe->cxe_name);
  1422.  
  1423.                   set (BT_CxAppear, MUIA_Disabled, !(cxe->cxe_flags_int & COF_SHOW_HIDE));
  1424.                   set (BT_CxDisappear, MUIA_Disabled, !(cxe->cxe_flags_int & COF_SHOW_HIDE));
  1425.                   set (BT_CxEnable, MUIA_Disabled, FALSE);
  1426.                   set (BT_CxDisable, MUIA_Disabled, FALSE);
  1427.                   set (BT_CxKill, MUIA_Disabled, FALSE);
  1428.                   set (BT_CxListChg, MUIA_Disabled, FALSE);
  1429.                   set (BT_CxUnique, MUIA_Disabled, FALSE);
  1430.                   set (BT_CxPriority, MUIA_Disabled, FALSE);
  1431.                   set (BT_CxRemove, MUIA_Disabled, FALSE);
  1432.                   if (! clientstate) {
  1433.                      set (BT_CxMore, MUIA_Disabled, FALSE);
  1434.                   }
  1435.                }
  1436.                break;
  1437.  
  1438.             case ID_CLASSPRINT:
  1439.                PrintClass (NULL);
  1440.                break;
  1441.  
  1442.             case ID_CLASSES:
  1443.             case ID_CLASSUPDATE:
  1444.                ClassWindow (TRUE);
  1445.                break;
  1446.  
  1447.             case ID_CLASSREMOVE:
  1448.                if (entryp = GetActiveEntry (classlist)) {
  1449.                   if (MyRequest ("Yes|No", "Do you really want to remove\nclass \'%s\'?", ((struct ClassEntry *) entryp)->cse_classname)) {
  1450.                      if (MyDoCommand ("RemoveClass %s", ((struct ClassEntry *) entryp)->cse_address)) {
  1451.                         RemoveActiveEntry (classlist);
  1452.                         SetCountText (classcount, --classcnt);
  1453.                      } else {
  1454.                         ShowClass();
  1455.                      }
  1456.                   }
  1457.                }
  1458.                break;
  1459.  
  1460.             case ID_CLASSMORE:
  1461.                if (entryp = GetActiveEntry (classlist))
  1462.                   GetClassMore((struct IClass *) ((struct ClassEntry *)entryp)->cse_adr);
  1463.                break;
  1464.  
  1465.             case ID_CLASSEXIT:
  1466.                ClassWindow (FALSE);
  1467.                break;
  1468.  
  1469.             case ID_CLASSLV_ACTIVE:
  1470.                if (entryp = GetActiveEntry (classlist)) {
  1471.                   MySetContentsHealed (classtext, "%s \"%s\"", ((struct ClassEntry *) entryp)->cse_address, ((struct ClassEntry *) entryp)->cse_classname);
  1472.  
  1473.                   set (BT_ClassRemove, MUIA_Disabled, FALSE);
  1474.                   if (! clientstate) {
  1475.                      set (BT_ClassMore, MUIA_Disabled, FALSE);
  1476.                   }
  1477.                }
  1478.                break;
  1479.  
  1480.             case ID_SMODEPRINT:
  1481.                PrintSMode (NULL);
  1482.                break;
  1483.  
  1484.             case ID_SCREENMODE:
  1485.             case ID_SMODEUPDATE:
  1486.                SModeWindow (TRUE);
  1487.                break;
  1488.  
  1489.             case ID_SMODEMORE:
  1490.                if (entryp = GetActiveEntry (smodelist))
  1491.                   GetSModeMore((struct SModeEntry *)entryp);
  1492.                break;
  1493.  
  1494.             case ID_SMODEEXIT:
  1495.                SModeWindow (FALSE);
  1496.                break;
  1497.  
  1498.             case ID_SMODELV_ACTIVE:
  1499.                if (entryp = GetActiveEntry (smodelist)) {
  1500.                   MySetContentsHealed (smodetext, "%s \"%s\"", ((struct SModeEntry *) entryp)->sme_id, ((struct SModeEntry *) entryp)->sme_name);
  1501.                   if (! clientstate) {
  1502.                      set (BT_SModeMore, MUIA_Disabled, FALSE);
  1503.                   }
  1504.                }
  1505.                break;
  1506.  
  1507.             case ID_LOCKPRINT:
  1508.                PrintLocks (NULL);
  1509.                break;
  1510.  
  1511.             case ID_LOCKS:
  1512.             case ID_LOCKUPDATE:
  1513.                LocksWindow (TRUE);
  1514.                break;
  1515.  
  1516.             case ID_LOCKREMOVE:
  1517.                {
  1518.                int tmpint = 1;
  1519.                id = -1;
  1520.                pos = -42;
  1521.  
  1522.                for (;;) {
  1523.                   DoMethod (locklist,MUIM_List_NextSelected,&id);
  1524.                   if ((id == -1) || (tmpint == 0)) break;
  1525.                   DoMethod (locklist,MUIM_List_GetEntry,id,&entryp);
  1526.                   if (entryp) {
  1527.                      if (tmpint != 2) { // ungleich ALL
  1528.                         tmpint = MyRequest ("Yes|All|No|Abort", "Do you really want to remove lock\n\'%s\'?", ((struct LockEntry *) entryp)->lock_path);
  1529.                      }
  1530.                      get (locklist,MUIA_List_Active,&pos);
  1531.                      if (pos == id) {
  1532.                         set (locklist,MUIA_List_Active,MUIV_List_Active_Off);
  1533.                      }
  1534.                      if ((tmpint == 1) || (tmpint == 2)) { // YES oder ALL
  1535.                         if (MyDoCommand ("RemoveLock %s", ((struct LockEntry *) entryp)->lock_address)) {
  1536.                            DoMethod (locklist, MUIM_List_Remove, id);
  1537.                            id -= 1;
  1538.                         }
  1539.                      } else if (tmpint == 3) {
  1540.                         DoMethod (locklist,MUIM_List_Select,id,MUIV_List_Select_Off,NULL);
  1541.                      }
  1542.                   }
  1543.                }
  1544.                }
  1545.                break;
  1546.  
  1547.             case ID_LOCKEXIT:
  1548.                LocksWindow (FALSE);
  1549.                break;
  1550.  
  1551.             case ID_LOCKLV_ACTIVE:
  1552.                if (entryp = GetActiveEntry (locklist)) {
  1553.                   MySetContents (locktext, "%s \"%s\"", ((struct LockEntry *) entryp)->lock_address, ((struct LockEntry *) entryp)->lock_path);
  1554.                   set (BT_LockRemove, MUIA_Disabled, FALSE);
  1555.                }
  1556.                break;
  1557.  
  1558.             case ID_PORTPRINT:
  1559.                PrintPorts (NULL);
  1560.                break;
  1561.  
  1562.             case ID_PORTS:
  1563.             case ID_PORTUPDATE:
  1564.                PortsWindow (TRUE);
  1565.                break;
  1566.  
  1567.             case ID_PORTREMOVE:
  1568.                if (entryp = GetActiveEntry (portlist)) {
  1569.                   if (MyRequest ("Yes|No", "Do you really want to remove port\n\'%s\'?", ((struct PortEntry *) entryp)->pt_name)) {
  1570.                      if (MyDoCommand ("RemovePort %s", ((struct PortEntry *) entryp)->pt_address)) {
  1571.                         RemoveActiveEntry (portlist);
  1572.                         SetCountText (portcount, --portcnt);
  1573.                      } else {
  1574.                         ShowPorts();
  1575.                      }
  1576.                   }
  1577.                }
  1578.                break;
  1579.  
  1580.             case ID_PORTPRIORITY:
  1581.                if (entryp = GetActiveEntry (portlist)) {
  1582.                   LONG tmppri;
  1583.  
  1584.                   if (GetPriority (((struct PortEntry *) entryp)->pt_name, ((struct PortEntry *) entryp)->pt_pri, &tmppri)) {
  1585.                      if (MyDoCommand ("SetPriority PORT \"%s\" %ld", ((struct PortEntry *) entryp)->pt_name, tmppri)) {
  1586.                         _sprintf (((struct PortEntry *) entryp)->pt_pri, "%4ld ", tmppri);
  1587.                      }
  1588.                      ShowPorts();
  1589.                   }
  1590.                }
  1591.                break;
  1592.  
  1593.             case ID_PORTMORE:
  1594.                if (node = HandleNodeDetails (portlist, "port"))
  1595.                   GetPortMore ((struct MsgPort *) node);
  1596.                break;
  1597.  
  1598.             case ID_PORTEXIT:
  1599.                PortsWindow (FALSE);
  1600.                break;
  1601.  
  1602.             case ID_PORTLV_ACTIVE:
  1603.                if (entryp = GetActiveEntry (portlist)) {
  1604.                   MySetContents (porttext, "%s \"%s\"", ((struct PortEntry *) entryp)->pt_address, ((struct PortEntry *) entryp)->pt_name);
  1605.                   set (BT_PortRemove, MUIA_Disabled, FALSE);
  1606.                   set (BT_PortPriority, MUIA_Disabled, FALSE);
  1607.  
  1608.                   if (! clientstate) {
  1609.                      set (BT_PortMore, MUIA_Disabled, FALSE);
  1610.                   }
  1611.                }
  1612.                break;
  1613.  
  1614.             case ID_MEMPRINT:
  1615.                PrintMemory (NULL);
  1616.                break;
  1617.  
  1618.             case ID_MEMORY:
  1619.                MemoryWindow (TRUE);
  1620.                break;
  1621.  
  1622.             case ID_MEMPRIORITY:
  1623.                if (entryp = GetActiveEntry (memlist)) {
  1624.                   LONG tmppri;
  1625.  
  1626.                   if (GetPriority (((struct MemoEntry *) entryp)->mem_name, ((struct MemoEntry *) entryp)->mem_pri, &tmppri)) {
  1627.                      if (MyDoCommand ("SetPriority MEMORY \"%s\" %ld", ((struct MemoEntry *) entryp)->mem_name, tmppri)) {
  1628.                         _sprintf (((struct MemoEntry *) entryp)->mem_pri, "%4ld ", tmppri);
  1629.                      }
  1630.                      ShowMemory();
  1631.                   }
  1632.                }
  1633.                break;
  1634.  
  1635.             case ID_MEMMORE:
  1636.                if (node = HandleNodeDetails (memlist, "memory"))
  1637.                   GetMemMore ((struct MemHeader *) node);
  1638.                break;
  1639.  
  1640.             case ID_MEMEXIT:
  1641.                MemoryWindow (FALSE);
  1642.                break;
  1643.  
  1644.             case ID_MEMLV_ACTIVE:
  1645.                if (entryp = GetActiveEntry (memlist)) {
  1646.                   MySetContents (memtext, "%s \"%s\"", ((struct MemoEntry *) entryp)->mem_address, ((struct MemoEntry *) entryp)->mem_name);
  1647.  
  1648.                   set (BT_MemPriority, MUIA_Disabled, FALSE);
  1649.  
  1650.                   if (! clientstate) {
  1651.                      set (BT_MemMore, MUIA_Disabled, FALSE);
  1652.                   }
  1653.                }
  1654.                break;
  1655.  
  1656.             case ID_MOUNTPRINT:
  1657.                PrintMounts (NULL);
  1658.                break;
  1659.  
  1660.             case ID_MOUNT:
  1661.             case ID_MOUNTUPDATE:
  1662.                MountWindow (TRUE);
  1663.                break;
  1664.  
  1665.             case ID_MOUNTMORE:
  1666.                if (entryp = GetActiveEntry (mountlist)) {
  1667.                   GetMountMore ((struct DeviceNode *) ((struct MountEntry *) entryp)->mt_adr);
  1668.                }
  1669.                break;
  1670.  
  1671.             case ID_MOUNTEXIT:
  1672.                MountWindow (FALSE);
  1673.                break;
  1674.  
  1675.             case ID_MOUNTLV_ACTIVE:
  1676.                if (entryp = GetActiveEntry (mountlist)) {
  1677.                   MySetContents (mounttext, "%s \"%s\"", ((struct MountEntry *) entryp)->mt_address, ((struct MountEntry *) entryp)->mt_name);
  1678.  
  1679.                   if (! clientstate) {
  1680.                      set (BT_MountMore, MUIA_Disabled, FALSE);
  1681.                   }
  1682.                }
  1683.                break;
  1684.  
  1685.             case ID_COMPRINT:
  1686.                PrintCommands (NULL);
  1687.                break;
  1688.  
  1689.             case ID_COMMANDS:
  1690.             case ID_COMUPDATE:
  1691.                CommandsWindow (TRUE);
  1692.                break;
  1693.  
  1694.             case ID_COMREMOVE:
  1695.                if ((((struct CommandEntry *) entryp)->cm_adr != NULL) && (entryp = GetActiveEntry (comlist))) {
  1696.  
  1697.                   if (((struct CommandEntry *) entryp)->cm_uc[0] == 'I') {
  1698.                      MyRequest ("Continue", "Can not remove INTERNAL commands!");
  1699.                   } else if (((struct CommandEntry *) entryp)->cm_uc[0] == 'S') {
  1700.                      MyRequest ("Continue", "Can not remove SYSTEM commands!");
  1701.                   } else if (((struct CommandEntry *) entryp)->cm_uc[0] == 'D') {
  1702.                      MyRequest ("Continue", "Can not remove DISABLED commands!");
  1703.                   } else {
  1704.                      if (MyRequest ("Yes|No", "Do you really want to remove command\n\'%s\'?", ((struct CommandEntry *) entryp)->cm_name)) {
  1705.                         if (MyDoCommand ("RemoveCommand %s", ((struct CommandEntry *) entryp)->cm_address)) {
  1706.                            SetCountText (comcount, --comcnt);
  1707.                            RemoveActiveEntry (comlist);
  1708.                            while (TRUE) {
  1709.                               if ((entryp = GetActiveEntry (comlist)) && (((struct CommandEntry *) entryp)->cm_address[0] == ' ')) {
  1710.                                  RemoveActiveEntry (comlist);
  1711.                               } else {
  1712.                                  break;
  1713.                               }
  1714.                            }
  1715.                         }
  1716.                      }
  1717.                   }
  1718.                }
  1719.                break;
  1720.  
  1721.             case ID_COMEXIT:
  1722.                CommandsWindow (FALSE);
  1723.                break;
  1724.  
  1725.             case ID_COMLV_ACTIVE:
  1726.                if (entryp = GetActiveEntry (comlist)) {
  1727.                   if (((struct CommandEntry *) entryp)->cm_adr == NULL) {
  1728.                      MySetContents (comtext, "");
  1729.                   } else {
  1730.                      MySetContents (comtext, "%s \"%s\"", ((struct CommandEntry *) entryp)->cm_address, ((struct CommandEntry *) entryp)->cm_name);
  1731.                   }
  1732.                   set (BT_ComRemove, MUIA_Disabled, FALSE);
  1733.                }
  1734.                break;
  1735.  
  1736.             case ID_INTPRINT:
  1737.                PrintInterrupts (NULL);
  1738.                break;
  1739.  
  1740.             case ID_INTERRUPTS:
  1741.             case ID_INTUPDATE:
  1742.                InterruptsWindow (TRUE);
  1743.                break;
  1744.  
  1745.             case ID_INTREMOVE:
  1746.                if (entryp = GetActiveEntry (intlist)) {
  1747.                   if (((struct IntEntry *) entryp)->int_kind[0] == 'H') {
  1748.                      MyRequest ("Resume", "Sorry, I can't remove an\ninterrupt handler!");
  1749.                   } else {
  1750.                      if (MyRequest ("Yes|No", "Do you really want to remove\n\'%s\'?", ((struct IntEntry *) entryp)->int_name)) {
  1751.                         MyDoCommand ("RemoveInterrupt \"%s\"", ((struct IntEntry *) entryp)->int_name);
  1752.                         ShowInterrupts();
  1753.                      }
  1754.                   }
  1755.                }
  1756.                break;
  1757.  
  1758.             case ID_INTMORE:
  1759.                if (entryp = GetActiveEntry (intlist)) {
  1760.                   GetIntMore ((struct IntEntry *) entryp);
  1761.                }
  1762.                break;
  1763.  
  1764.             case ID_INTEXIT:
  1765.                InterruptsWindow (FALSE);
  1766.                break;
  1767.  
  1768.             case ID_INTLV_ACTIVE:
  1769.                if (entryp = GetActiveEntry (intlist)) {
  1770.                   MySetContents (inttext, "%s \"%s\"", ((struct IntEntry *) entryp)->int_address, ((struct IntEntry *) entryp)->int_name);
  1771.                   set (BT_IntRemove, MUIA_Disabled, FALSE);
  1772.  
  1773.                   if (! clientstate) {
  1774.                      set (BT_IntMore, MUIA_Disabled, FALSE);
  1775.                   }
  1776.                }
  1777.                break;
  1778.  
  1779.             case ID_SEMPRINT:
  1780.                PrintSemaphores (NULL);
  1781.                break;
  1782.  
  1783.             case ID_SEMAPHORES:
  1784.             case ID_SEMUPDATE:
  1785.                SemaphoresWindow (TRUE);
  1786.                break;
  1787.  
  1788.             case ID_SEMOBTAIN:
  1789.                if (entryp = GetActiveEntry (semlist)) {
  1790.                   if (MyRequest ("Yes|No", "Do you really want to obtain semaphore\n\'%s\'?", ((struct SemEntry *) entryp)->sm_name)) {
  1791.                      if (MyDoCommand ("ObtainSemaphore %s", ((struct SemEntry *) entryp)->sm_address)) {
  1792.                         ShowSemaphores();
  1793.                      } else {
  1794.                         ShowSemaphores();
  1795.                      }
  1796.                   }
  1797.                }
  1798.                break;
  1799.  
  1800.             case ID_SEMRELEASE:
  1801.                if (entryp = GetActiveEntry (semlist)) {
  1802.                   long  tmplong;
  1803.  
  1804.                   if ((IsDec (((struct SemEntry *) entryp)->sm_nestcount, &tmplong)) && (tmplong)) {
  1805.                      if (MyRequest ("Yes|No", "Do you really want to release semaphore\n\'%s\'?", ((struct SemEntry *) entryp)->sm_name)) {
  1806.                         MyDoCommand ("ReleaseSemaphore %s", ((struct SemEntry *) entryp)->sm_address);
  1807.                         ShowSemaphores();
  1808.                      }
  1809.                   } else {
  1810.                      MyRequest ("Continue", "Sorry, the nestcount is already zero!");
  1811.                   }
  1812.                }
  1813.                break;
  1814.  
  1815.             case ID_SEMREMOVE:
  1816.                if (entryp = GetActiveEntry (semlist)) {
  1817.                   long tmplong;
  1818.  
  1819.                   if ((IsDec (((struct SemEntry *) entryp)->sm_nestcount, &tmplong)) && (tmplong)) {
  1820.                      MyRequest ("Continue", "Sorry, the nestcount is not zero!");
  1821.                   } else {
  1822.                      if (MyRequest ("Yes|No", "Do you really want to remove semaphore\n\'%s\'?", ((struct SemEntry *) entryp)->sm_name)) {
  1823.                         MyDoCommand ("RemoveSemaphore %s", ((struct SemEntry *) entryp)->sm_address);
  1824.                         ShowSemaphores();
  1825.                      }
  1826.                   }
  1827.                }
  1828.                break;
  1829.  
  1830.             case ID_SEMEXIT:
  1831.                SemaphoresWindow (FALSE);
  1832.                break;
  1833.  
  1834.             case ID_SEMLV_ACTIVE:
  1835.                if (entryp = GetActiveEntry (semlist)) {
  1836.                   MySetContents (semtext, "%s \"%s\"", ((struct SemEntry *) entryp)->sm_address, ((struct SemEntry *) entryp)->sm_name);
  1837.                   set (BT_SemObtain, MUIA_Disabled, FALSE);
  1838.                   set (BT_SemRelease, MUIA_Disabled, FALSE);
  1839.                   set (BT_SemRemove, MUIA_Disabled, FALSE);
  1840.                }
  1841.                break;
  1842.  
  1843.             case ID_INPUTPRINT:
  1844.                PrintInputHandlers (NULL);
  1845.                break;
  1846.  
  1847.             case ID_INPUTHANDLER:
  1848.             case ID_INPUTUPDATE:
  1849.                InputHandlerWindow (TRUE);
  1850.                break;
  1851.  
  1852.             case ID_INPUTREMOVE:
  1853.                if (entryp = GetActiveEntry (inputlist)) {
  1854.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%s\'?", ((struct InputEntry *) entryp)->input_name)) {
  1855.                      if (MyDoCommand ("RemoveInputhandler %s", ((struct InputEntry *) entryp)->input_address)) {
  1856.                         SetCountText (inputcount, --inputcnt);
  1857.                         RemoveActiveEntry (inputlist);
  1858.                      } else {
  1859.                         ShowInputHandler();
  1860.                      }
  1861.                   }
  1862.                }
  1863.                break;
  1864.  
  1865.             case ID_INPUTPRIORITY:
  1866.                if (entryp = GetActiveEntry (inputlist)) {
  1867.                   LONG tmppri;
  1868.  
  1869.                   if (GetPriority (((struct InputEntry *) entryp)->input_name, ((struct InputEntry *) entryp)->input_pri, &tmppri)) {
  1870.                      if (MyDoCommand ("SetPriority INPUTHANDLER \"%s\" %ld", ((struct InputEntry *) entryp)->input_name, tmppri)) {
  1871.                         _sprintf (((struct InputEntry *) entryp)->input_pri, "%4ld ", tmppri);
  1872.                      }
  1873.                      ShowInputHandler();
  1874.                   }
  1875.                }
  1876.                break;
  1877.  
  1878.             case ID_INPUTEXIT:
  1879.                InputHandlerWindow (FALSE);
  1880.                break;
  1881.  
  1882.             case ID_INPUTLV_ACTIVE:
  1883.                if (entryp = GetActiveEntry (inputlist)) {
  1884.                   MySetContents (inputtext, "%s \"%s\"", ((struct InputEntry *) entryp)->input_address, ((struct InputEntry *) entryp)->input_name);
  1885.                   set (BT_InputRemove, MUIA_Disabled, FALSE);
  1886.                   set (BT_InputPriority, MUIA_Disabled, FALSE);
  1887.                }
  1888.                break;
  1889.  
  1890.             case ID_EXPPRINT:
  1891.                PrintExpansions (NULL);
  1892.                break;
  1893.  
  1894.             case ID_EXPANSIONS:
  1895.                ExpansionsWindow (TRUE);
  1896.                break;
  1897.  
  1898.             case ID_EXPMORE:
  1899.                if (entryp = GetActiveEntry (explist)) {
  1900.                   GetExpansionMore ((struct ConfigDev *) ((struct ExpEntry *) entryp)->exp_adr);
  1901.                }
  1902.                break;
  1903.  
  1904.             case ID_EXPEXIT:
  1905.                ExpansionsWindow (FALSE);
  1906.                break;
  1907.  
  1908.             case ID_EXPLV_ACTIVE:
  1909.                if (entryp = GetActiveEntry (explist)) {
  1910.                   _sprintf(tmpstr,"Size=%s Flags=%s ID=%s:%s SN=%s",
  1911.                       ((struct ExpEntry *)entryp)->exp_boardsize,
  1912.                       ((struct ExpEntry *)entryp)->exp_flags,
  1913.                       ((struct ExpEntry *)entryp)->exp_manufacturer,
  1914.                       ((struct ExpEntry *)entryp)->exp_product,
  1915.                       ((struct ExpEntry *)entryp)->exp_serialnumber);
  1916.                   set (exptext,MUIA_Text_Contents,tmpstr);
  1917.  
  1918.                   if (!clientstate) {
  1919.                      set (BT_ExpMore, MUIA_Disabled, FALSE);
  1920.                   }
  1921.                }
  1922.                break;
  1923.  
  1924.             case ID_RESIPRINT:
  1925.                PrintResidents (NULL);
  1926.                break;
  1927.  
  1928.             case ID_RESIDENTS:
  1929.             case ID_RESIUPDATE:
  1930.                ResidentsWindow (TRUE);
  1931.                break;
  1932.  
  1933.             case ID_RESIMORE:
  1934.                if (entryp = GetActiveEntry (resilist)) {
  1935.                   GetResiMore (((struct ResiEntry *) entryp)->rt_adr);
  1936.                }
  1937.                break;
  1938.  
  1939.             case ID_RESIEXIT:
  1940.                ResidentsWindow (FALSE);
  1941.                break;
  1942.  
  1943.             case ID_RESILV_ACTIVE:
  1944.                if (entryp = GetActiveEntry (resilist)) {
  1945.                   MySetContentsHealed (resitext, "%s \"%s\"", ((struct ResiEntry *) entryp)->rt_address, ((struct ResiEntry *) entryp)->rt_name);
  1946.  
  1947.                   if (! clientstate) {
  1948.                      set (BT_ResiMore, MUIA_Disabled, FALSE);
  1949.                   }
  1950.                }
  1951.                break;
  1952.  
  1953.             case ID_WINPRINT:
  1954.                PrintWindows (NULL);
  1955.                break;
  1956.  
  1957.             case ID_WINDOWS:
  1958.             case ID_WINUPDATE:
  1959.                WindowsWindow (TRUE);
  1960.                break;
  1961.  
  1962.             case ID_WINCLOSE:
  1963.                if (entryp = GetActiveEntry (winlist)) {
  1964.                   if (((struct WinEntry *) entryp)->wn_type == 'S') {
  1965.                      if ((! clientstate) && (((struct Screen *) ((struct WinEntry *) entryp)->wn_adr)->FirstWindow)) {
  1966.                         if (MyRequest ("Yes|No", "Do you really want to close this\n%s?", "screen with all its windows")) {
  1967.                            MyDoCommand ("CloseScreen %s", ((struct WinEntry *) entryp)->wn_address + 2);
  1968.                            ShowWindows();
  1969.                         }
  1970.                      } else {
  1971.                         if (MyRequest ("Yes|No", "Do you really want to close this\n%s?", "screen")) {
  1972.                            MyDoCommand ("CloseScreen %s", ((struct WinEntry *) entryp)->wn_address + 2);
  1973.                            ShowWindows();
  1974.                         }
  1975.                      }
  1976.                   } else {
  1977.                      if (MyRequest ("Yes|No", "Do you really want to close this\n%s?", "window")) {
  1978.                         MyDoCommand ("CloseWindow %s", ((struct WinEntry *) entryp)->wn_address);
  1979.                         ShowWindows();
  1980.                      }
  1981.                   }
  1982.                }
  1983.                break;
  1984.  
  1985.             case ID_WINTOFRONT:
  1986.                if (entryp = GetActiveEntry (winlist)) {
  1987.                   if (((struct WinEntry *) entryp)->wn_type == 'S') {
  1988.                      MyDoCommand ("PopToFront %s", ((struct WinEntry *) entryp)->wn_address + 2);
  1989.                   } else {
  1990.                      MyDoCommand ("PopToFront %s", ((struct WinEntry *) entryp)->wn_address);
  1991.                   }
  1992.                }
  1993.                break;
  1994.  
  1995.             case ID_WINMORE:
  1996.                if (entryp = GetActiveEntry (winlist)) {
  1997.                   if (((struct WinEntry *) entryp)->wn_type == 'W') {
  1998.                      struct Window *tmpwindow;
  1999.  
  2000.                      if (tmpwindow = MyFindWindow (((struct WinEntry *) entryp)->wn_address))
  2001.                         GetWindowMore (tmpwindow);
  2002.                      else
  2003.                         MyRequest ("Continue", "Sorry, can't find that %s!", "window");
  2004.                   } else {
  2005.                      struct Screen *tmpscreen;
  2006.  
  2007.                      if (tmpscreen = MyFindScreen (((struct WinEntry *) entryp)->wn_address + 2))
  2008.                         GetScreenMore (tmpscreen);
  2009.                      else
  2010.                         MyRequest ("Continue", "Sorry, can't find that %s!", "screen");
  2011.                   }
  2012.                }
  2013.                break;
  2014.  
  2015.             case ID_WINEXIT:
  2016.                WindowsWindow (FALSE);
  2017.                break;
  2018.  
  2019.             case ID_WINLV_ACTIVE:
  2020.                if (entryp = GetActiveEntry (winlist)) {
  2021.                   if (((struct WinEntry *) entryp)->wn_type == 'S') {
  2022.                      MySetContentsHealed (wintext, "%s \"%s\"", ((struct WinEntry *) entryp)->wn_address, ((struct WinEntry *) entryp)->wn_title);
  2023.                   } else {
  2024.                      MySetContentsHealed (wintext, "%s \"%s\"", ((struct WinEntry *) entryp)->wn_address, ((struct WinEntry *) entryp)->wn_title);
  2025.                   }
  2026.                   set (BT_WinClose, MUIA_Disabled, FALSE);
  2027.                   set (BT_WinToFront, MUIA_Disabled, FALSE);
  2028.  
  2029.                   if (! clientstate) {
  2030.                      set (BT_WinMore, MUIA_Disabled, FALSE);
  2031.                   }
  2032.                }
  2033.                break;
  2034.  
  2035.             case ID_ALCPRINT:
  2036.                PrintAllocations (NULL);
  2037.                break;
  2038.  
  2039.             case ID_ALLOCATIONS:
  2040.             case ID_ALCUPDATE:
  2041.                AllocationsWindow (TRUE);
  2042.                break;
  2043.  
  2044.             case ID_ALCEXIT:
  2045.                AllocationsWindow (FALSE);
  2046.                break;
  2047.  
  2048.             case ID_ASSPRINT:
  2049.                PrintAssigns (NULL);
  2050.                break;
  2051.  
  2052.             case ID_ASSIGNS:
  2053.             case ID_ASSUPDATE:
  2054.                AssignsWindow (TRUE);
  2055.                break;
  2056.  
  2057.             case ID_ASSREMOVE:
  2058.                if (entryp = GetActiveEntry (asslist)) {
  2059.                   if (((struct AssEntry *) entryp)->ass_path[0] == ' ') {
  2060.                      if (MyRequest ("Yes|No", "Do you really want to remove directory\n\'%s\' from assign '%s:\'?", ((struct AssEntry *) entryp)->ass_path +4, ((struct AssEntry *) entryp)->ass_name)) {
  2061.                         if (MyDoCommand ("RemoveAssignList %s $%lx", ((struct AssEntry *) entryp)->ass_name, ((struct AssEntry *) entryp)->ass_adr)) {
  2062.                            SetCountText (asscount, --asscnt);
  2063.                            RemoveActiveEntry (asslist);
  2064.                         } else {
  2065.                            ShowAssigns();
  2066.                         }
  2067.                      }
  2068.                   } else {
  2069.                      if (MyRequest ("Yes|No", "Do you really want to remove assign\n\'%s:\'?", ((struct AssEntry *) entryp)->ass_name)) {
  2070.                         if (MyDoCommand ("RemoveAssign %s", ((struct AssEntry *) entryp)->ass_name)) {
  2071.                            SetCountText (asscount, --asscnt);
  2072.                            RemoveActiveEntry (asslist);
  2073.                            while (TRUE) {
  2074.                               if ((entryp = GetActiveEntry (asslist)) && (((struct AssEntry *) entryp)->ass_path[0] == ' ')) {
  2075.                                  RemoveActiveEntry (asslist);
  2076.                               } else {
  2077.                                  break;
  2078.                               }
  2079.                            }
  2080.                         } else {
  2081.                            ShowAssigns();
  2082.                         }
  2083.                      }
  2084.                   }
  2085.                }
  2086.                break;
  2087.  
  2088.             case ID_ASSEXIT:
  2089.                AssignsWindow (FALSE);
  2090.                break;
  2091.  
  2092.             case ID_ASSLV_ACTIVE:
  2093.                if (entryp = GetActiveEntry (asslist)) {
  2094.                   if (((struct AssEntry *) entryp)->ass_path[0] != ' ') {
  2095.                      MySetContents (asstext, "%s \"%s\"", ((struct AssEntry *) entryp)->ass_address, ((struct AssEntry *) entryp)->ass_path);
  2096.                   } else {
  2097.                      MySetContents (asstext, "%s \"%s\"", ((struct AssEntry *) entryp)->ass_address, ((struct AssEntry *) entryp)->ass_path +4);
  2098.                   }
  2099.                   set (BT_AssRemove, MUIA_Disabled, FALSE);
  2100.                }
  2101.                break;
  2102.  
  2103.             case ID_FONTPRINT:
  2104.                PrintFonts (NULL);
  2105.                break;
  2106.  
  2107.             case ID_FONTS:
  2108.             case ID_FONTUPDATE:
  2109.                FontsWindow (TRUE);
  2110.                break;
  2111.  
  2112.             case ID_FONTCLOSE:
  2113.                if (entryp = GetActiveEntry (fontlist)) {
  2114.                   int tmpint, tmpint2;
  2115.  
  2116.                   if ((IsDec (((struct FontEntry *) entryp)->font_count, (long *) &tmpint2)) && (tmpint2)) {
  2117.                      if (tmpint = MyRequest ("Once|All|Cancel", "Do you really want to close\n\"%s\"?", ((struct FontEntry *) entryp)->font_name)) {
  2118.                         if (tmpint == 1) {
  2119.                            MyDoCommand ("CloseFont %s", ((struct FontEntry *) entryp)->font_address);
  2120.                         } else {
  2121.                            while (tmpint2) {
  2122.                               if (! MyDoCommand ("CloseFont %s", ((struct FontEntry *) entryp)->font_address)) {
  2123.                                  break;
  2124.                               }
  2125.                               tmpint2--;
  2126.                            }
  2127.                         }
  2128.                         ShowFonts ();
  2129.                      }
  2130.                   } else {
  2131.                      MyRequest ("Continue", "Sorry, the count of accessors is already zero!");
  2132.                   }
  2133.                }
  2134.                break;
  2135.  
  2136.             case ID_FONTREMOVE:
  2137.                if (entryp = GetActiveEntry (fontlist)) {
  2138.                   long  tmplong;
  2139.  
  2140.                   if ((IsDec (((struct FontEntry *) entryp)->font_count, &tmplong)) && (tmplong)) {
  2141.                      MyRequest ("Continue", "Sorry, the count of accessors is not zero!");
  2142.                   } else {
  2143.                      if (MyRequest ("Yes|No", "Do you really want to remove\n\"%s\" from system?", ((struct FontEntry *) entryp)->font_name)) {
  2144.                         MyDoCommand ("RemoveFont %s", ((struct FontEntry *) entryp)->font_address);
  2145.                         ShowFonts ();
  2146.                      }
  2147.                   }
  2148.                }
  2149.                break;
  2150.  
  2151.             case ID_FONTEXIT:
  2152.                FontsWindow (FALSE);
  2153.                break;
  2154.  
  2155.             case ID_FONTLV_ACTIVE:
  2156.                if (entryp = GetActiveEntry (fontlist)) {
  2157.                   MySetContents (fonttext, "%s \"%s\"", ((struct FontEntry *) entryp)->font_address, ((struct FontEntry *) entryp)->font_name);
  2158.                   set (BT_FontClose, MUIA_Disabled, FALSE);
  2159.                   set (BT_FontRemove, MUIA_Disabled, FALSE);
  2160.                   set (LB_FontExample, FDATTR_Font, ((struct FontEntry *) entryp)->font_adr);
  2161.                }
  2162.                break;
  2163.  
  2164.             case ID_VECPRINT:
  2165.                PrintVectors (NULL);
  2166.                break;
  2167.  
  2168.             case ID_VECTORS:
  2169.             case ID_VECUPDATE:
  2170.                VectorsWindow (TRUE);
  2171.                break;
  2172.  
  2173.             case ID_VECEXIT:
  2174.                VectorsWindow (FALSE);
  2175.                break;
  2176.  
  2177.             case ID_SYSPRINT:
  2178.                PrintSystem (NULL);
  2179.                break;
  2180.  
  2181.             case ID_SYSTEM:
  2182.             case ID_SYSUPDATE:
  2183.                SystemWindow (TRUE);
  2184.                break;
  2185.  
  2186.             case ID_SYSEXIT:
  2187.                SystemWindow (FALSE);
  2188.                break;
  2189.  
  2190.             case ID_FLUSHDEVS:
  2191.                MyDoCommand ("FLUSHDEVS");
  2192.                break;
  2193.  
  2194.             case ID_FLUSHFONTS:
  2195.                MyDoCommand ("FLUSHFONTS");
  2196.                break;
  2197.  
  2198.             case ID_FLUSHALL:
  2199.                MyDoCommand ("FLUSHALL");
  2200.                break;
  2201.  
  2202.             case ID_FLUSHLIBS:
  2203.                MyDoCommand ("FLUSHLIBS");
  2204.                break;
  2205.  
  2206.             case ID_REMOVEWINFREE:
  2207.                if (WinFree_ToDo) {
  2208.                   RemoveWinFree ();
  2209.                   WinFree_ToDo = NULL;
  2210.                }
  2211.                break;
  2212.  
  2213.             case ID_FLAGWINDOW:
  2214.                if (WinFlag_ToDo) {
  2215.                   GetFlagsMore (WinFlag_ToDo->wf_title2, WinFlag_ToDo->wf_fieldname, WinFlag_ToDo->wf_flags, WinFlag_ToDo->wf_longflag, WinFlag_ToDo->wf_mlongflag, WinFlag_ToDo->wf_fieldtype);
  2216.                   WinFlag_ToDo = NULL;
  2217.                }
  2218.                break;               
  2219.  
  2220.             case ID_CLEARRESET:
  2221.                ClearResetVectors();
  2222.                break;
  2223.  
  2224.             case ID_ABOUT:
  2225.                AboutWindow (TRUE);
  2226.                break;
  2227.  
  2228.             case ID_ABOUTCONTINUE:
  2229.                AboutWindow (FALSE);
  2230.                break;
  2231.  
  2232.             case ID_LIBSORT:
  2233.                                    get (CY_LibSort,MUIA_Cycle_Active,&libsortstate);
  2234.                liblist_cmphook_ptr = LibSortList[libsortstate];
  2235.                ShowLibraries();
  2236.                break;
  2237.  
  2238.             case ID_DEVSORT:
  2239.                                    get (CY_DevSort,MUIA_Cycle_Active,&devsortstate);
  2240.                devlist_cmphook_ptr = LibSortList[devsortstate];
  2241.                ShowDevices();
  2242.                break;
  2243.  
  2244.             case ID_RESSORT:
  2245.                                    get (CY_ResSort,MUIA_Cycle_Active,&ressortstate);
  2246.                reslist_cmphook_ptr = LibSortList[ressortstate];
  2247.                ShowResources();
  2248.                break;
  2249.  
  2250.             case ID_TASKSORT:
  2251.                                    get (CY_TaskSort,MUIA_Cycle_Active,&tasksortstate);
  2252.                tasklist_cmphook_ptr = TaskSortList[tasksortstate];
  2253.                ShowTasks();
  2254.                break;
  2255.  
  2256.             case ID_CXSORT:
  2257.                                    get (CY_CxSort,MUIA_Cycle_Active,&cxsortstate);
  2258.                cxlist_cmphook_ptr = CxSortList[cxsortstate];
  2259.                ShowCx();
  2260.                break;
  2261.  
  2262.             case ID_CLASSSORT:
  2263.                                    get (CY_ClassSort,MUIA_Cycle_Active,&classsortstate);
  2264.                classlist_cmphook_ptr = ClassSortList[classsortstate];
  2265.                ShowClass();
  2266.                break;
  2267.  
  2268.             case ID_SMODESORT:
  2269.                                    get (CY_SModeSort,MUIA_Cycle_Active,&smodesortstate);
  2270.                smodelist_cmphook_ptr = SModeSortList[smodesortstate];
  2271.                ShowSMode();
  2272.                break;
  2273.  
  2274.             case ID_PORTSORT:
  2275.                                    get (CY_PortSort,MUIA_Cycle_Active,&portsortstate);
  2276.                portlist_cmphook_ptr = PortSortList[portsortstate];
  2277.                ShowPorts();
  2278.                break;
  2279.  
  2280.             case ID_COMSORT:
  2281.                                    get (CY_ComSort,MUIA_Cycle_Active,&comsortstate);
  2282.                comlist_cmphook_ptr = ComSortList[comsortstate];
  2283.                ShowCommands();
  2284.                break;
  2285.  
  2286.             case ID_ASSSORT:
  2287.                                    get (CY_AssSort,MUIA_Cycle_Active,&asssortstate);
  2288.                asslist_cmphook_ptr = AssSortList[asssortstate];
  2289.                ShowAssigns();
  2290.                break;
  2291.  
  2292.             case ID_LOCKSORT:
  2293.                                    get (CY_LockSort,MUIA_Cycle_Active,&locksortstate);
  2294.                locklist_cmphook_ptr = LockSortList[locksortstate];
  2295.                ShowLocks();
  2296.                break;
  2297.  
  2298.             case ID_LOWMEMORYPRINT:
  2299.                PrintLowMemory (NULL);
  2300.                break;
  2301.  
  2302.             case ID_LOWMEMORY:
  2303.             case ID_LOWMEMORYUPDATE:
  2304.                LowMemoryWindow (TRUE);
  2305.                break;
  2306.  
  2307. /*
  2308.             case ID_LOWMEMORYCAUSE:
  2309.                if (entryp = GetActiveEntry (lowmemorylist)) {
  2310.                   MyDoCommand ("CauseLowMemory %s", ((struct LowMemoryEntry *) entryp)->lowmemory_address);
  2311.                }
  2312.                break;
  2313. */
  2314.  
  2315.             case ID_LOWMEMORYREMOVE:
  2316.                if (entryp = GetActiveEntry (lowmemorylist)) {
  2317.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%s\'?", ((struct LowMemoryEntry *) entryp)->lowmemory_name)) {
  2318.                      if (MyDoCommand ("RemoveLowMemory %s", ((struct LowMemoryEntry *) entryp)->lowmemory_address)) {
  2319.                         SetCountText (lowmemorycount, --lowmemorycnt);
  2320.                         RemoveActiveEntry (lowmemorylist);
  2321.                      } else {
  2322.                         ShowLowMemory();
  2323.                      }
  2324.                   }
  2325.                }
  2326.                break;
  2327.  
  2328.             case ID_LOWMEMORYPRIORITY:
  2329.                if (entryp = GetActiveEntry (lowmemorylist)) {
  2330.                   LONG tmppri;
  2331.  
  2332.                   if (GetPriority (((struct LowMemoryEntry *) entryp)->lowmemory_name, ((struct LowMemoryEntry *) entryp)->lowmemory_pri, &tmppri)) {
  2333.                      if (MyDoCommand ("SetPriority LOWMEMORY \"%s\" %ld", ((struct LowMemoryEntry *) entryp)->lowmemory_name, tmppri)) {
  2334.                         _sprintf (((struct LowMemoryEntry *) entryp)->lowmemory_pri, "%4ld ", tmppri);
  2335.                      }
  2336.                      ShowLowMemory();
  2337.                   }
  2338.                }
  2339.                break;
  2340.  
  2341.             case ID_LOWMEMORYEXIT:
  2342.                LowMemoryWindow (FALSE);
  2343.                break;
  2344.  
  2345.             case ID_LOWMEMORYLV_ACTIVE:
  2346.                if (entryp = GetActiveEntry (lowmemorylist)) {
  2347.                   MySetContents (lowmemorytext, "%s \"%s\"", ((struct LowMemoryEntry *) entryp)->lowmemory_address, ((struct LowMemoryEntry *) entryp)->lowmemory_name);
  2348. //*                  set (BT_LowMemoryCause, MUIA_Disabled, FALSE);
  2349.                   set (BT_LowMemoryRemove, MUIA_Disabled, FALSE);
  2350.                   set (BT_LowMemoryPriority, MUIA_Disabled, FALSE);
  2351.                }
  2352.                break;
  2353.  
  2354.             case ID_TIMERPRINT:
  2355.                PrintTimer (NULL);
  2356.                break;
  2357.  
  2358.             case ID_TIMER:
  2359.             case ID_TIMERUPDATE:
  2360.                TimerWindow (TRUE);
  2361.                break;
  2362.  
  2363. /*
  2364.             case ID_TIMERREMOVE:
  2365.                if (entryp = GetActiveEntry (timerlist)) {
  2366.                   if (MyRequest ("Yes|No", "Do you really want to remove\n\'%s\'?", ((struct TimerEntry *) entryp)->timer_name)) {
  2367.                      if (MyDoCommand ("RemoveTimer %s", ((struct TimerEntry *) entryp)->timer_address)) {
  2368.                         SetCountText (timercount, --timercnt);
  2369.                         RemoveActiveEntry (timerlist);
  2370.                      } else {
  2371.                         ShowTimer();
  2372.                      }
  2373.                   }
  2374.                }
  2375.                break;
  2376. */
  2377.             case ID_TIMEREXIT:
  2378.                TimerWindow (FALSE);
  2379.                break;
  2380.  
  2381.             case ID_TIMERLV_ACTIVE:
  2382.                if (entryp = GetActiveEntry (timerlist)) {
  2383.                   MySetContents (timertext, "%s \"%s\"", ((struct TimerEntry *) entryp)->timer_address, ((struct TimerEntry *) entryp)->timer_name);
  2384. //*                  set (BT_TimerRemove, MUIA_Disabled, FALSE);
  2385.                }
  2386.                break;
  2387.  
  2388.             default:
  2389.                break;
  2390.          }
  2391.  
  2392.          if (running && signal) {
  2393.             signal = (signal | 0x0000f000 | 0x01<<TimerSignal);
  2394.             received = Wait (signal);
  2395.          }         
  2396.  
  2397. //         aprintf ("\nSIGNAL: $%08lx  RECEIVED: $%08lx\n", signal, received);
  2398.  
  2399.          if (0x7000 & received) {
  2400.             running = FALSE;
  2401.             aprintf ("***Break\n");
  2402.          }
  2403.  
  2404.          if (0x8000 & received)
  2405.             set (AP_Scout,MUIA_Application_Iconified,FALSE);
  2406.  
  2407.          if (0x01<<TimerSignal & received) {
  2408. //            tmpint++;
  2409.             GetMsg(ScoutPort);
  2410.             HandleTimerRequest (TRUE);
  2411.          }
  2412.  
  2413.          signal = (signal & 0xffff0fff & 0x01<<TimerSignal);
  2414.       }
  2415.    }
  2416.  
  2417.    if (opts.Host) {
  2418.       SendDaemon (CMD_END);
  2419.    }
  2420.    fail();
  2421.    return (RETURN_OK);
  2422. }
  2423.  
  2424. /*********************************************************************
  2425.  END:                           MAIN
  2426. *********************************************************************/
  2427.